Android-如何制作无限滚动视图

时间:2020-03-10 10:56:09

标签: android uiscrollview scrollview custom-scrolling

我正在尝试为用户提供一个可以无限滚动的背景。 我已经在XML的滚动视图中添加了一堆图像视图,但是我很难找到一种确保背景永不耗尽的方法。 当用户到达末尾时,理想情况下,最上面的图像应自动重新定位到视图下方,以便始终有更多滚动内容。

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/layout"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none">
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="match_parent">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/tp_texture_long"/>
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/tp_texture_long"/>
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/tp_texture_long"/>
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/tp_texture_long"/>
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/tp_texture_long"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

看看this的答案。但是您应该使用RecyclerView而不是ListView