Disable the swipe gesture that opens the navigation drawer in android
you can use the drawerlockmode
in the screen navigation options using the option locked-open
the drawer can be locked in 3 states:
unlocked (default)- meaning that the drawer will respond (open/close) to touch gestures.
locked-closed- meaning that the drawer will stay closed and not respond to gestures.
locked-open- meaning that the drawer will stay opened and not respond to gestures.
locked-open: the drawer will stay opened and not respond to gestures. the drawer may still be opened and closed programmatically
To disable swipe on the right drawer view, you will need to pass it. However, if you are using a layout structure with both left and right side menus, it can be challenging to disable only one of them. Attempting to use statements like the one mentioned will lock the entire DrawerLayout, preventing swiping on either side menu.
Is there any way of disable the swipe to
open drawer in android studio
Is there a method to prevent the swipe gesture from activating the drawer?
I have attempted to achieve this by using the code
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED).
Unfortunately, the view cannot be opened by clicking the icon due to this issue.
My only requirement is to deactivate the gesture that triggers its opening.
Solution:
Try using this method before opening and closing the drawer.
It has worked for me, so it might work for you as well.
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Post a Comment
0Comments