How to detect that the navigation box was opened by scrolling (rather than the home icon)?

I am using Navigation Box in my android application.

Since this is a template that is actually hard for me to find, my plan was to add a small message at the bottom of the screen until the user finally found it and successfully opened it with a swipe.

I know I can use:

public void onDrawerOpened(View drawerView) { // Stop telling the user, he know how it works } 

But this action also starts when you open it with the left button in the ActionBar.

Any suggestion of finding a successful wipe will be warmly welcome.

+6
source share
2 answers

You need to listen to the state change callback:

  @Override public void onDrawerStateChanged(int newState) { if (newState == DrawerLayout.STATE_DRAGGING) { Log.v(TAG, "Drawer opened by dragging"); } } 

This condition occurs only when the user drags the box into view. Clicking on the home icon does not cause this - this is exactly what you want.

+6
source

Without the DrawerLayout extension, you can use a combination of DrawerListener and the Boolean flag for the Home button.

Deploy DrawerListener using the onDrawerSlide method. Inside this method, you can check the "Main button" flag, and if it is false and the box is shifted, you know that this action is through a slide.

Bit mess.

In addition, override the DrawerLayout and override the onTouchEvent and catch move events.

+2
source

Source: https://habr.com/ru/post/947592/


All Articles