android - 如何为无限滚动的 RecyclerView 绘制背景

标签 android listview scroll android-recyclerview background

我正在为 Android 应用程序开发一个无限滚动列表,使用 RecyclerView View 组和一个 OnScrollListener 在用户滚动到最后一个项目后添加项目RecyclerView 的。

现在想在项目后面的中间添加一条黑线,作为一种回收 View 。

enter image description here

如您所见,项目可以有不同的高度。

实现此目标的最佳(也是最高效)方法是什么?

最佳答案

您可以考虑使用如下布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/your_background">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/your_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent" />
</RelativeLayout>

关于android - 如何为无限滚动的 RecyclerView 绘制背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49964375/

相关文章:

java - Android 加速计每次返回相同的值

android - 如何通过切换按钮调整整个 ListView 的大小?

android - 如何像自定义 ListView 一样创建自定义 ImageView ?

javascript - 如果启用触摸事件,iScroll 将不起作用

javascript - 元素淡出和淡入时如何保持DOM位置

java - 悬停在 Android 中的按钮上意味着什么?

android - 在 Android 上使用 GoogleSignInClient 静默签名时出现 ApiException

android - (Android) Layout 不会在 setVisibility(view.GONE) 后重绘?

c# - 在 WPF ListView 中如何防止自动滚动?

jquery - 窗口滚动 : avoid multiple api hits based on scroll height