在DrawerLayout上禁用手势监听器

我如何禁用DrawerLayout的手势识别? (从左向右滑动),只接受closures手势(从右向左),并使用主屏幕button打开抽屉?

这对我工作:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); 

您可以通过点击主页button来展开抽屉,并可以使用从右向左轻扫手势将其解除。 但是,从左向右轻扫不再被触发。

对于setDrawerLockMode() ,这是在代码中,而不是在Android开发人员文档:

 /** * 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; 

要禁用DrawerLayout手势识别,请使用:

 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN); 

然后,要启用从右到左滑动,请检查此资源: http : //android-journey.blogspot.com/2010/01/android-gestures.html