问题
Hi all my need is that buttons must show at bottom, so my code as
<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>
But when items in list are less (until scroll bar of list view is not enable), Buttons are visible, but when items in list are more, buttons are not visible, although I scrolled list item to last row, but at last buttons are not displaying. How can I solve it.
Thank you!
回答1:
LinearLayout
is giving ListView
all the space it needs, because it considers its children sequentially and doesn't take into account those that follow.
My suggestion is to use RelativeLayout.
<RelativeLayout ...>
<ListView ...
android:id="@+id/list"
android:layout_alignParentTop="true"/>
<LinearLayout ...
android:layout_below="@id/list"
android:layout_alignParentBottom="true">
...buttons...
</LinearLayout>
</RelativeLayout>
回答2:
I am not sure. But you may try to set the weight of your listview.
<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>
回答3:
You can set the minimumheight of listview e.g. 320*480 listview height = 430 button's layout height = 50
来源:https://stackoverflow.com/questions/4873523/buttons-not-displaying-in-linear-layout