how to scroll RecyclerView in scrollview
10,190
Solution 1
Don't use RecyclerView
inside ScrollView
. Use NestedScrollView
instead of ScrollView
.
NestedScrollView
is just likeScrollView
, 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);
![Adil Saiyad](https://i.stack.imgur.com/9lOxU.jpg?s=256&g=1)
Author by
Adil Saiyad
I am Senior Android & Xamarin Android Developer at Self Employed. I complete M.C.A at Dept. of Computer Science Bhavnagar.
Updated on June 16, 2022Comments
-
Adil Saiyad about 2 years
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 almost 7 yearsabove code not work.whole scrollview scroll if scroll
-
Adil Saiyad almost 7 yearsabove code not work.whole scrollview scroll if scroll
-
Ferdous Ahamed almost 7 yearspost you current layout xml.
-
Adil Saiyad almost 7 yearsit looks like your post is mostly code; please add some more details.
-
Adil Saiyad almost 7 yearsbut now above code resize as per data not show scrolling option i have to show scroll option after some fix size
-
Gautam Singh almost 7 yearswhat you exactly want, i think you want scroll multiple recyclerview and some recyclerview horizontally
-
Ferdous Ahamed almost 7 yearsthen use
fixed height
to yourRecyclerViews
using attributelayout_height
orlayout_weight
-
Adil Saiyad almost 7 yearsLet us continue this discussion in chat.
-
Ferdous Ahamed almost 7 yearsGlad to know that. If my answer seems useful then please mark as right answer and i hope you will give an up-vote too.