Disable the swipe gesture that opens the navigation drawer in android

Jyotishgher Astrology
By -
0

Disable the swipe gesture that opens the navigation drawer in android

Is there any way to disable swipe gesture to open navigation drawer? Its really annoying when menu appears while swiping between tabs.

you can use the drawerlockmode in the screen navigation options using the option locked-open

How do I turn off swipe gesture on Android?

Settings > Apps & notifications > Default apps > Assistant & voice input > tap "Google" > select "None". Hit the arrow and this gesture is gone

the drawer can be locked in 3 states:

  1. unlocked (default)- meaning that the drawer will respond (open/close) to touch gestures.

  2. locked-closed- meaning that the drawer will stay closed and not respond to gestures.

  3. locked-open- meaning that the drawer will stay opened and not respond to gestures.

locked-openthe 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

Question:

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.

This should work like a charm

for locking you can do this:
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
and for unlock :
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

Post a Comment

0Comments

Post a Comment (0)