简体   繁体   中英

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 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!

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>

您可以设置列表视图的最小高度,例如320 * 480列表视图高度= 430按钮的布局高度= 50

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM