【问题标题】:Fixed footer not displaying the bottom-most list item固定页脚不显示最底部的列表项
【发布时间】:2011-05-30 05:29:41
【问题描述】:

这是我的 XML 布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
 <ListView xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/list" 
  android:orientation="vertical"
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content">
 </ListView>

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent"
     android:layout_alignParentBottom="true">
    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" 
        android:layout_weight="1" />
    <Button xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_weight="2" />
 </LinearLayout>
</RelativeLayout>

导致这个问题的原因:

列表视图项(红色轮廓)在固定页脚后面,不能使用。任何解决方案?
更新:
我宁愿指出我的代码中的更改以解决该问题,然后进行某种解释。但这只是我的偏好。

【问题讨论】:

    标签: android xml listview footer


    【解决方案1】:

    我刚刚知道怎么做。通过使用RelativeLayout 并将代码更改为:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/root"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <LinearLayout
           android:id="@+id/listview_footer"
           android:layout_height="wrap_content"
           android:layout_width="fill_parent"
           android:layout_alignParentBottom="true">
           <EditText
               android:id="@+id/new_task_title"
               android:layout_height="wrap_content"
               android:layout_width="fill_parent" 
               android:layout_weight="1"
               android:hint="Add a new task" />
           <Button
               android:id="@+id/new_task_button"
               android:layout_height="wrap_content"
               android:layout_width="fill_parent"
               android:layout_weight="3"
               android:text="+" />
        </LinearLayout>
    
        <ListView
            android:id="@android:id/list" 
            android:orientation="vertical"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:layout_below="@id/root"
            android:layout_above="@id/listview_footer">
        </ListView>
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2015-11-14
      • 2017-04-04
      • 1970-01-01
      • 2013-10-24
      • 2013-09-25
      • 2013-01-24
      • 1970-01-01
      • 2016-12-01
      相关资源
      最近更新 更多