Disable gesture listener in DrawerLayout

How to disable gesture recognition for DrawerLayout? (swipe the screen from left to right) and accept only a lowercase gesture (from right to left) and open the box using the home button only?

+49
android drawerlayout
Jun 10 '13 at 14:14
source share
4 answers

This worked for me:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); 

You can expand the box by pressing the "Home" button, and you can use swipe gestures from right to left to cancel it. However, left-right scrolling no longer starts.

+118
Jul 18 '13 at 4:21
source share

For setDrawerLockMode() this is in the code, but not in the Android developer docs:

 /** * The drawer is unlocked. */ public static final int LOCK_MODE_UNLOCKED = 0; /** * The drawer is locked closed. The user may not open it, though * the app may open it programmatically. */ public static final int LOCK_MODE_LOCKED_CLOSED = 1; /** * The drawer is locked open. The user may not close it, though the app * may close it programmatically. */ public static final int LOCK_MODE_LOCKED_OPEN = 2; 
+18
Apr 08 '14 at 17:48
source share

To disable DrawerLayout gesture recognition, use:

 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN); 

Then, to enable scrolling from right to left, check this resource: http://android-journey.blogspot.com/2010/01/android-gestures.html

+4
Jul 12 '13 at 7:26
source share

Looks like I found a mistake. For example, if installed:

 android:layout_gravity="right" 

or

 android:layout_gravity="left" 

for the contents of the box and using .setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) everything will be fine.

But if android:layout_gravity="left|center_vertical" or something like this LOCK_MODE_LOCKED_CLOSED will not work.

0
Dec 15 '17 at 11:21
source share



All Articles