Stefano Vuerich Stefano Vuerich - 4 months ago 23x
Android Question

Disable DrawerLayout's scrim touch gesture

enter image description here

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 layout is open and I need to select an element from the ListView below the red highlighted part, what's happend is that the drawer get closed and only at this point I can select an element from the ListView.

I need to select the element from the ListView directly, also when the Drawer is opened


You have to create custom drawer for that like this

public class CustomDrawer extends DrawerLayout {

    public CustomDrawer(Context context) {


    public CustomDrawer(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);


    public CustomDrawer(Context context, AttributeSet attrs) {
        super(context, attrs);


    public boolean onInterceptTouchEvent(MotionEvent event) {
            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