Outer Recyclerview Not Receiving Scroll Events Of Inner Recyclerview
I followed this tutorial to implement the behaviors for both hiding the toolbar and the FAB when scrolled: https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is
Solution 1:
Hank Moody comment actually lead me to the correct answer - thanks Hank!
This is how I solved my problem:
Create a 'Scroll Through' recyclerview where the parent will receive all the scroll events of the child by doing this:
publicclassScrollThroughRecyclerViewextendsRecyclerView { publicScrollThroughRecyclerView(Context context) { super(context); } publicScrollThroughRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); } publicScrollThroughRecyclerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @OverridepublicbooleandispatchTouchEvent(MotionEvent ev){ //true - block scrolling of child and allow scrolling for parent recyclerreturntrue; } }
Use this custom recyclerview in your xml or in your java code and the scroll events will be passed correctly to your parent recyclerview which will activate the app scrollbehavior.
Solution 2:
if you want put one vertical recycler in another vertical you must set fixed height for child recycler view, or try to overwrite this method
@OverridepublicbooleandispatchTouchEvent(MotionEvent ev){
//false - block scrolling of parent recycler and allow scrolling for childreturnfalse;
}
Solution 3:
Have you tried using the following in the xml of the inner recyclerview?
app:layout_behavior="@string/appbar_scrolling_view_behavior"
EDIT: assuming you are using CoordinatorLayout.
Post a Comment for "Outer Recyclerview Not Receiving Scroll Events Of Inner Recyclerview"