如何为无休止的滚动RecyclerView绘制背景

时间:2018-04-22 09:17:16

标签: android listview scroll android-recyclerview background

我正在为Android应用开发一个无尽的可滚动列表,使用RecyclerView视图组和OnScrollListener我在用户滚动到{{1}的最后一项后添加项目}。

现在想要在项目后面的中间添加一条黑线作为回收者视图。

enter image description here

如您所见,这些物品可以有不同的高度。

什么是最好(也是最高效)的方式来实现这个目标?

1 个答案:

答案 0 :(得分:1)

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

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