【问题标题】:Android - How to make an infinite Scroll ViewAndroid - 如何制作无限滚动视图
【发布时间】:2020-06-22 06:23:12
【问题描述】:

我正在尝试制作一个用户可以无限滚动的背景。 我已经在 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 并重复图像。如果你想无限向下滚动,你的内存使用情况如何?
  • 计划是在滚动时删除高于阈值的图像。

标签: android uiscrollview scrollview custom-scrolling


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2013-10-28
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2014-12-12
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多