簡體   English   中英

Android - 如何制作無限滾動視圖

[英]Android - How to make an infinite Scroll View

我正在嘗試制作一個用戶可以無限滾動的背景。 我在 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>

我該怎么做?

看看這個答案。 但是您應該使用RecyclerView而不是ListView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM