How to use vertical RecyclerView inside ScrollView on Android

Arman Kolahan
1 min readMay 24, 2020

It was one of my problems, how to design nested vertical RecyclerView inside ScrollView in Android. The answer is:

androidx.core.widget.NestedScrollView

It should be mentioned that in this case, the RecyclerView is NOT the RecyclerView anymore!

In the first step, you need to create NestedScrollView element in XML:

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

// RecyclerViews should be located here

</LinearLayout>
</androidx.core.widget.NestedScrollView>

Next, add the below attribute to recyclerView:

android:overScrollMode="never"

Then, the recyclerView will be as following:

<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />

Finally, the whole the layout will be something like below, you can add other materials inside LinearLayout:

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
// other materials </LinearLayout>
</androidx.core.widget.NestedScrollView>

--

--

Arman Kolahan

Experienced frontend engineer & architect with over a decade of expertise in React. Proven leader and team builder. Passionate writer.