【发布时间】:2018-03-26 07:40:30
【问题描述】:
我有一个父母LinearLayout,里面有两个孩子LinearLayout。我在第一个子布局中有 4 个 TextView,在第二个子布局中有 2 个 TextView。父布局具有属性android:layout_height="wrap_content 以及子布局。
我想将第一个子布局的高度设置为第二个子布局,因为第一个子布局有 4 个文本框,而第二个子布局必须有文本框。
我只想调整第二个子布局的高度。我把我的代码放在下面。
<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>
【问题讨论】:
-
给出第二个布局 android:layout_height="match_parent"
-
你想要什么
post your screenshot here ? -
@VishalYadav,我解决了。
标签: android android-layout android-linearlayout