I am using a Navigation Drawer in my Android app.
As this is a pattern that I find really hard to discover, my plan was to add a little message at the bottom of the screen until the user finally discover it and succesfully opened it with a swipe.
I know that I could use:
public void onDrawerOpened(View drawerView) {
// Stop telling the user, he know how it works
}
But this action is also triggered when opening it with the upper left button in the ActionBar.
Any suggestion to detect a succesfull swipe would be warmly welcome.
The user can view the navigation drawer when the user swipes a finger from the left edge of the activity. They can also find it from the home activity by tapping the app icon in the action bar. The drawer icon is displayed on all top-level destinations that use a DrawerLayout.
Just add closeDrawer() inside onNavigationItemSelected() to close the drawer on selecting any item on Navigation Drawer.
The navigation drawer is a UI panel that shows your app's main navigation menu. The drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen.
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 state only occurs when user drags the drawer into view. Tapping on home icon does not induce this - which is exactly what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With