0

I am trying to make a background that the user can scroll through infinitely (i.e scroll never ends). I have added a bunch of image views to the scroll view in XML, however, I am having trouble finding a way to make sure that the background never runs out. When the user reaches the end, ideally the top images should automatically relocate to below the view so that there is always more to scroll.

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

How would I do this?

Coder101
  • 17
  • 2
  • Use nestedscrollview – MMG Mar 10 '20 at 10:57
  • Can you please post an answer on how to do that and if it works i can mark as correct, never used it before – Coder101 Mar 10 '20 at 10:57
  • Why do you want to scroll down unfinitely? You may put images in a recyclerview and repeat images. If you want to scroll down unfinitely, what about your memory usage? – MMG Mar 10 '20 at 11:07
  • The plan was to remove images above the threshold when you scroll. – Coder101 Mar 10 '20 at 14:20

1 Answers1

0

Have a look at this answer. But you should use a RecyclerView instead of ListView.

Frank D.
  • 26
  • 4