I need to disable touch gesture on the scrim (the red highlighted part). I want to dismiss the drawer only with the swipe.
The issue is that when the drawer lay
You have to create custom drawer for that like this
public class CustomDrawer extends DrawerLayout {
public CustomDrawer(Context context) {
super(context);
}
public CustomDrawer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public CustomDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if(isDrawerOpen(Gravity.START)){
if(event.getX() > getChildAt(1).getWidth()){
return false;
}
}
return super.onInterceptTouchEvent(event);
}
}
Note : getChildAt(1)
should be that child to whom you have given gravity as "start" and whose width determines the width of opening drawer.
I hope this should solve your problem