我想创建一个具有两个LinearLayout(垂直位置)的布局。
第一个linearLayout占空间的80%,另外20%(我使用的是weightSum = 10)。
在第二个布局上,我有一个textinput,当键盘出现时,屏幕尺寸减小,因此第二个线性布局有20%太小。
我希望我的secondLayout最少有100dp,第一个布局要有其余的但我不知道如何实现它。
谢谢!
答案 0 :(得分:2)
当总和大于LinearLayout时,权重用于分配剩余的空白空间或占用空间。将宽度设置为0dip,它将起作用。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum:"10" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="8" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="2">
</LinearLayout>
</LinearLayout>