![](/img/trans.png)
[英]How to detect RecyclerView scroll due to bottom-most item height decrease?
[英]Fixed footer not displaying the bottom-most list item
這是我的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>
這導致了這個問題:
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.