Last updated on August 28th, 2020 at 05:11 pm

In this tutorial I will explain how we can add Nested ScrollView in Android Application. This post helps you to understand how simple it is to implement scroll if you are using multiple recycler view in a single screen. For example, if we want to implement Image Slider in top of the screen and after slider, we want to implement RecyclerView then we implement both inside nested scroll view as shown in below image.

This was a screenshot of one of my project in which I implement Slider and after that, I implement RecyclerView to load the list of more products. Now without wasting more time let get started.

Step 1. Hope you already Implement Image Slider and RecyclerView in a single screen, If you want to learn about RecyclerView and adapter read this post.

Step 2. Now we implement NestedScrollView in our screen as shown below.

<android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <com.shivam.library.imageslider.ImageSlider
                android:layout_width="match_parent"
                android:layout_height="300dp"
                android:id="@+id/pager"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/categoryList"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </android.support.v7.widget.RecyclerView>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

Step 3. Now in our code, if we want to us NestedScrollView we need to disable RecyclerScroll using a simple single line of code as shown below.

RecyclerView categoryList = (RecyclerView)findViewById(R.id.categoryList);
categoryList.setNestedScrollingEnabled(false);

Find RecyclerView from layout and disable ScrollView using single line setNestedScrollingEnabled. 

That’s it. Hope this simple post helps you to implement NestedScrollView with RecyclerView in Android Application.