开发者

Buttons not displaying in linear layout

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 a开发者_StackOverflow社区re 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!


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>


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>


You can set the minimumheight of listview e.g. 320*480 listview height = 430 button's layout height = 50

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜