[英]Buttons not displaying in linear layout
大家好,我的需要是按钮必须显示在底部,所以我的代码为
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="12dip">
<ListView
android:id="@+id/list_multiselectable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
</ListView>
<LinearLayout android:orientation="horizontal"
android:background="@android:drawable/bottom_bar"
android:paddingLeft="4.0dip" android:paddingTop="5.0dip"
android:paddingRight="4.0dip" android:paddingBottom="1.0dip"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
my buttons code here
</LinearLayout>
</LinearLayout>
但是当列表中的项目较少时(直到未启用列表视图的滚动条),按钮才可见,但是当列表中的项目较多时,按钮却不可见,尽管我将列表项滚动到了最后一行,但最后一个按钮不显示。 我该怎么解决呢
谢谢!
LinearLayout
为ListView
提供了所需的所有空间,因为它顺序地考虑其子级,并且不考虑其后的子级。
我的建议是使用RelativeLayout。
<RelativeLayout ...>
<ListView ...
android:id="@+id/list"
android:layout_alignParentTop="true"/>
<LinearLayout ...
android:layout_below="@id/list"
android:layout_alignParentBottom="true">
...buttons...
</LinearLayout>
</RelativeLayout>
我不确定。 但是您可以尝试设置列表视图的权重。
<ListView
android:id="@+id/list_multiselectable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_gravity="center_vertical">
</ListView>
您可以设置列表视图的最小高度,例如320 * 480列表视图高度= 430按钮的布局高度= 50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.