0

I am having a Linearlayout which is having a Textview and the Recyclerview. The problem is that when RecyclerView's data is increased then when we scroll, the Textview above the recyclerview keeps it position i.e. not scrolled and only RecyclerView's contents are scrolled. I want whole screen to be scroll instead of only RecyclerView scrolling.

<LinearLayout>
  <TextView/>
  <RecyclerView>
</LinearLayout>

Thanks

Gulfam
  • 558
  • 6
  • 27
  • you can use ItemDecoration as shown in answer [here](https://stackoverflow.com/a/33458426/10429259) – Bhavin Feb 02 '22 at 12:20

1 Answers1

0

Add NestedScrollView as parent of LinearLayout to scroll whole screen.

Try below code:

 <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
            <androidx.recyclerview.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:nestedScrollingEnabled="false"/>
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
Android Geek
  • 8,956
  • 2
  • 21
  • 35