简体   繁体   English

按钮未以线性布局显示

[英]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. LinearLayoutListView提供了所需的所有空间,因为它顺序地考虑其子级,并且不考虑其后的子级。

My suggestion is to use RelativeLayout. 我的建议是使用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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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