如何将TextView放在recyclerView列表的末尾

问题描述 投票:0回答:1

我想在recyclerView列表的末尾添加一个简单的TextView,以帮助用户在找不到所需的项目时使用。但是,就像android上的所有内容一样,没有什么比这简单,而且文档也毫无价值。

请注意,我不想通过Recyclerview适配器操作(如此处建议的那样)实现此目的:

How to add a button at the end of RecyclerView?

我尝试了很多选择,并在Google上阅读。以下是我的最后尝试

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.circularreveal.coordinatorlayout.CircularRevealCoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    tools:context=".collaborate.CollaborateActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
    <include
        android:id="@+id/collaborate_toolbar"
        layout="@layout/toolbar" />
    </com.google.android.material.appbar.AppBarLayout>


    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/collaborate_rv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="80dp"
                android:clipToPadding="false"
                android:useDefaultMargins="true"
                android:alignmentMode="alignBounds"
                android:columnOrderPreserved="false"
                tools:listitem="@layout/list_collaborate" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Didn't find what you were looking for? try...."/>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>


    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/collaborate_fb_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:layout_marginEnd="8dp"
        android:src="@drawable/check" />

</com.google.android.material.circularreveal.coordinatorlayout.CircularRevealCoordinatorLayout>
android android-recyclerview android-nestedscrollview
1个回答
0
投票
[另一种可能的方法是使用RecyclerView的ScrollListener检测列表结尾。如果列表结束,请显示您的TextView。
© www.soinside.com 2019 - 2024. All rights reserved.