I'm trying to implement a Navigation Drawer that hides the menu items in the ActionBar whenever the drawer is opened.
I am following google's documentation, however their code does not produce the expected behavior.
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Using this code, the menu items are hidden when the drawer becomes completely opened , and shown when the drawer becomes completely closed.
However, the Gmail app behaves differently. The menu items are hidden as soon as the drawer opens by any amount. This is the behavior I want. Does anyone know how to achieve this?
Thanks!
Best Answer
Have you tried this:
invalidateOptionsMenu()
whenever you toggle the nav drawer, by measuring the sliding offset.Iterate over each menu item in
onPrepareOptionsMenu(Menu menu)
and hide it.Detecting how much the nav drawer has slided:
Note:
shouldGoInvisible
is class field.