Fixed footer not displaying the bottom-most list item

早过忘川 提交于 2019-12-02 07:40:49

问题


Here is my XML layout:

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

Which causes this problem:


The listview item (outlined in red) is behind the fixed footer and cannot be used. Any solutions?
UPDATE:
I would prefer to be pointed out the changes in my code to fix that problem and then some sort of explanation. But that's just my preference.

回答1:


I just found out how. By utilizing the RelativeLayout and by changing the code to this:

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


来源:https://stackoverflow.com/questions/4523328/fixed-footer-not-displaying-the-bottom-most-list-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!