How To Scroll Recyclerview Inside Collapsingtoolbarlayout
I have recyclerview inside CollapsingToolbarLayout and I want it to be scrollable, but it is not. When I scroll, appbar is scrolling but not recyclerview. I tried different things,
Solution 1:
I Found solution:
recyclerView.addOnItemTouchListener(newRecyclerView.OnItemTouchListener() {
@OverridepublicbooleanonInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
int action = e.getAction();
switch (action) {
caseMotionEvent.ACTION_MOVE:
rv.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
returnfalse;
}
@OverridepublicvoidonTouchEvent(RecyclerView rv, MotionEvent e) {
}
@OverridepublicvoidonRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
Solution 2:
Set The Horizontal Track as false in Appbarlayout
This Fixed the problem. Do Let me know if it's not working
Code
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#fff"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar2"
android:scrollbarAlwaysDrawHorizontalTrack="false"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@style/TransparentText">
Post a Comment for "How To Scroll Recyclerview Inside Collapsingtoolbarlayout"