android - 固定页脚不显示最底部的列表项

标签 android xml listview footer

这是我的 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>

导致此问题的原因:
The problem
ListView 项目(红色轮廓)位于固定页脚后面,无法使用。有什么解决办法吗?
更新:
我更愿意被指出我的代码中的更改以解决该问题,然后进行某种解释。但这只是我的偏好。

最佳答案

我刚刚知道怎么做。通过利用 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>

关于android - 固定页脚不显示最底部的列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4523328/

相关文章:

java - 'int org.ksoap2.serialization.KvmSerializable.getPropertyCount()' 在空对象引用上

java - 同时获取所有通知

javascript - 当 ListView 没有返回数据时 jQuery 出错

Android exception.getMessage() 杀死 App

android - linphone Android.mk文件安卓

java - 请放心 : Verify xml value for of child tags

android - Android RecyclerView 中的一个按钮单击会触发另一个按钮

css - 为什么这个组合框的底部有一行?

.net - 是否有用于 .NET 的 XmlEncode/XmlDecode?

python - 如何忽略xml文件中的特定标签?