desactiva el gesto de deslizar que abre el cajón de navegación en Android
He estado siguiendo la guía del cajón de navegación de Google y me gustaría agregarla a una Actividad con pestañas y gestos.
Me gustaría desactivar el gesto para abrir el cajón de navegación, ¿alguien tiene alguna idea de cómo hacer esto?
5 answers
Debes usar:
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Funciona conmigo, el golpe para abrir el cajón estaba desactivado.
Si todavía no funciona, echa un vistazo a la respuesta proporcionada aquí.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:54:40
Para bloquear puedes hacer esto:
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Y para desbloquear :
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-13 12:00:48
Agregue también valor de gravedad cuando use setDrawerLockMode ();
Haz esto:
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);
Esto debería funcionar como un encanto
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-10 10:13:28
Para desactivar el barrido reemplazar onInterceptTouchEvent
y onTouchEvent
en DrawerLayout
y les devuelve falso.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-04 13:16:19
La respuesta para desactivar el deslizado es la correcta. Creo que LOCK_MODE_LOCKED_CLOSED funcionó en Compat 24.x, pero la funcionalidad se ha cambiado en las nuevas bibliotecas compat y LOCK_MODE_LOCKED_CLOSED ahora evita completamente que el menú nav se muestre, incluso mediante el uso del menú hamburguesa.
La siguiente clase funciona para mí (Kotlin):
class MyDrawerLayout(ctx: Context) : DrawerLayout(ctx) {
var isSwipeOpenEnabled: Boolean = true
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
if (!isSwipeOpenEnabled && !isDrawerVisible(Gravity.START)) {
return false
}
return super.onInterceptTouchEvent(ev)
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(ev: MotionEvent): Boolean {
if (!isSwipeOpenEnabled && !isDrawerVisible(Gravity.START)) {
return false
}
return super.onTouchEvent(ev)
}
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-04 06:49:26