Reputation: 111
I have one parent LinearLayout
and inside it I have two child LinearLayout
. I have 4 TextView
in 1st child layout and 2 TextView
in 2nd child layout. Parent layout has property android:layout_height="wrap_content
as well as child layout too.
I want to set height of 1st child layout to 2nd child layout because 1st child layout has 4 textbox and 2nd child layout has to textbox.
I just want to adjust the height of 2nd child layout. I am putting my code below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".8"
android:orientation="vertical">
<TextView
android:id="@+id/lblBooking_Code"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lblSession"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lblCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/lblAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/lblMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:orientation="vertical">
<TextView
android:id="@+id/lblBooking_Gross_Amt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lblBooking_PayAmt"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/lblBooking_Balance"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 207
Reputation: 111
Making the height of 2nd child layout "match_parent" and implementing "weightSum=3" I achieved my requirement.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".8"
android:orientation="vertical">
<TextView
android:id="@+id/lblBooking_Code"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lblSession"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lblCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/lblAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/lblMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".1"
android:weightSum="3"
android:orientation="vertical">
<TextView
android:id="@+id/lblBooking_Gross_Amt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/lblBooking_PayAmt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/lblBooking_Balance"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Upvotes: 0