how to scroll RecyclerView in scrollview

10,190

Solution 1

Don't use RecyclerView inside ScrollView. Use NestedScrollView instead of ScrollView.

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

For Example:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:descendantFocusability="blocksDescendants">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_one"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_two"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_three"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

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

Use attribute android:nestedScrollingEnabled="false" for smooth scrolling.

Solution 2

Use NestedScrollView instead of scroll view and set

recyclerView.setNestedScrollingEnabled(false);
Share:
10,190
Adil Saiyad
Author by

Adil Saiyad

I am Senior Android &amp; Xamarin Android Developer at Self Employed. I complete M.C.A at Dept. of Computer Science Bhavnagar.

Updated on June 16, 2022

Comments

  • Adil Saiyad
    Adil Saiyad about 2 years

    enter image description here

    how to scroll all above RecyclerView in scrollview

    I have to implement RecyclerView in scrollview show as below code, but not scroll RecyclerView.

    please give answer

                <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/horizontalScrollView"
                android:layout_marginTop="10dp">
    
              <RelativeLayout...
    
                            <android.support.v7.widget.RecyclerView
                                android:id="@+id/rvpouch"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:nestedScrollingEnabled="false"
                                android:layout_below="@+id/textView3">
    
    
                            </android.support.v7.widget.RecyclerView>
    
                        </RelativeLayout>
    
            </ScrollView>
    
  • Adil Saiyad
    Adil Saiyad almost 7 years
    above code not work.whole scrollview scroll if scroll
  • Adil Saiyad
    Adil Saiyad almost 7 years
    above code not work.whole scrollview scroll if scroll
  • Ferdous Ahamed
    Ferdous Ahamed almost 7 years
    post you current layout xml.
  • Adil Saiyad
    Adil Saiyad almost 7 years
    it looks like your post is mostly code; please add some more details.
  • Adil Saiyad
    Adil Saiyad almost 7 years
    but now above code resize as per data not show scrolling option i have to show scroll option after some fix size
  • Gautam Singh
    Gautam Singh almost 7 years
    what you exactly want, i think you want scroll multiple recyclerview and some recyclerview horizontally
  • Ferdous Ahamed
    Ferdous Ahamed almost 7 years
    then use fixed height to your RecyclerViews using attribute layout_height or layout_weight
  • Adil Saiyad
    Adil Saiyad almost 7 years
  • Ferdous Ahamed
    Ferdous Ahamed almost 7 years
    Glad to know that. If my answer seems useful then please mark as right answer and i hope you will give an up-vote too.