wyłącz gest machnięcia, który otwiera szufladę nawigacyjną w systemie android

Śledziłem przewodnik po szufladzie nawigacyjnym Google i chciałbym dodać go do aktywności z kartami i gestami.

Chciałbym wyłączyć gest otwierania szuflady nawigacyjnej, czy ktoś ma jakiś pomysł jak to zrobić?

Author: Alexander Farber, 2013-06-11

5 answers

Powinieneś użyć:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
To działa ze mną, machnięcie, aby otworzyć szufladę było wyłączone.

Jeśli nadal nie działa, sprawdź odpowiedź podaną tutaj .

 355
Author: Tran Hieu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:54:40

Do blokowania możesz to zrobić:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

I do odblokowania:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
 76
Author: saleh sereshki,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-13 12:00:48

Dodaj też wartość grawitacji podczas używania setDrawerLockMode ();

Zrób to:

drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);

To powinno działać jak urok

 12
Author: Burhan Shakir,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-10 10:13:28

Aby wyłączyć przesuwanie, Nadpisz onInterceptTouchEvent i onTouchEvent na DrawerLayout i niech zwrócą false.

 2
Author: HelloWorld,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-04 13:16:19

ODPOWIEDŹ na wyłączenie przesuwania jest prawidłowa. Myślę, że LOCK_MODE_LOCKED_CLOSED działał w Compat 24.x, ale funkcjonalność została zmieniona w nowszych bibliotekach compat i LOCK_MODE_LOCKED_CLOSED teraz całkowicie uniemożliwia wyświetlanie menu nav, nawet za pomocą menu hamburger.

Działa dla mnie następująca Klasa (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)
  }
}
 1
Author: Martin Vysny,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-04 06:49:26