Recyclerview Inside A Scrollview/nestedscrollview Does Not Scroll Properly
Solution 1:
When you have multiple scrolling Views in your layout (eg. RecyclerView + ScrollView) and when you scroll while in your recyclerView, the recyclerView scrolls with the parent Scrollview. this causes jitters in RecyclerView. You can avoid this jitter by the following.
You can add android:nestedScrollingEnabled="false"
to your RecyclerView in XML or recyclerView.setNestedScrollingEnabled(false);
to your RecyclerView in Java.
Solution 2:
If you want to support devices older than api 21 then you should use
ViewCompat.setNestedScrollingEnabled(mRecyclerView, false);
in your Activity/Fragment
Solution 3:
You have to do multiple tasks:
- put your recyclerview inside a
android.support.v4.widget.NestedScrollView
instead of normalScrollView
- set your recyclerview
android:nestedScrollingEnabled="true"
in layout XML file - to support devices older than API 21 then you should use
ViewCompat.setNestedScrollingEnabled(mRecyclerView, false)
in your code - set your RecyclerView height to
android:layout_height="wrap_content"
(or width if it is horizontal!)
Solution 4:
Besides Setting the android:nestedScrollingEnabled="false"
you need to make sure that the parent of the RecyclerView is a android.support.v4.widget.NestedScrollView
I had troubles that the RecyclerView did not measure properly (on big screens) when it was in a standard ScrollView
Solution 5:
if you want to scroll RecyclerView inside ScrollView and ScrollView prevents from scrolling RecyclerView (in API 16 this occurred) you should use android.support.v4.widget.NestedScrollView instead of ScrollView and also you must set nestedScrollView.setNestedScrollingEnabled(false); by this way you can prevent from scrolling nestedScrollView when you scroll RecyclerView. hope this help some one
Post a Comment for "Recyclerview Inside A Scrollview/nestedscrollview Does Not Scroll Properly"