You must disable touch event capture on DrawerLayout when the user scrolls to RecyclerView . Therefore, create a custom DrawerLayout as follows:
public class DrawerLayoutHorizontalSupport extends DrawerLayout { private RecyclerView mRecyclerView; private NavigationView mNavigationView; public DrawerLayoutHorizontalSupport(Context context) { super(context); } public DrawerLayoutHorizontalSupport(Context context, AttributeSet attrs) { super(context, attrs); } public DrawerLayoutHorizontalSupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (isInside(ev) && isDrawerOpen(mNavigationView)) return false; return super.onInterceptTouchEvent(ev); } private boolean isInside(MotionEvent ev) {
And after inflating your layout, just call set and pass in your NavigationView and RecyclerView .
In onInterceptTouchEvent I check if the box is open and the user touched inside the RecyclerView , then I return false, so DrawerLayout does nothing
source share