问题
I have a Recyclerview with GridLayoutManager whose child items may have a vertical RecyclerView inside it. Here is the screenshot:
I have created adapters for this scenario. It shows it properly but internal Recyclerview is not scrolling no matter how many items are inside it. Can anyone suggest how to make internal and main RecyclerViews scroll?
回答1:
I found the solution. I just had to disable the touch event of the parent in case Recyclerview receives touch event. Here is the code snippet that worked for me:
RecyclerView.OnItemTouchListener mScrollTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
rv.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
};
recyclerView.addOnItemTouchListener(mScrollTouchListener);
I found the answer here: Recyclerview inside Scrollview
来源:https://stackoverflow.com/questions/42858634/recyclerview-inside-recyclerview-is-not-scrolling