I have a NavigationDrawer
and hide/show the OptionsMenu
(which is located on the bottom due to a split ActionBar
) whenever the drawer gets opened/closed:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!isDrawerOpened) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
return false;
}
I would like to hide the Menu
with an animation, (for reference: like the animation used by the system when you call ActionBar.hide()
), however I found no way to access the Layout
used for the Menu
(so I could get a View
object to apply the animation to). It seems there's no public API available to perform this, I wouldn't mind some reflection approach if I knew what to look for. Any suggestions?
UPDATE
looking at this source I finally figured out how to access the View
of a split ActionBar
using a non-public identifier:
private View getSplitActionBarView() {
Window window = getWindow();
View v = window.getDecorView();
return v.findViewById(getResources().getIdentifier("split_action_bar",
"id", "android"));
}
Now I can create an Animation
, set an AnimationListener
and call invalidateOptionsMenu()
as soon as the Animation
ends. There's one problem left: doing this will let an ugly white rectangle at the place where the bottom part of the ActionBar
was, this white rectangle will stay there until the Animation
is complete. To get rid of it I would need to use <item name="android:windowActionBarOverlay">true</item>
in my style XML (or doing the same by code) to display the ActionBar
in overlay mode. However this is not what I need.
The question is now: is there any way to apply the overlay mode only to the split ActionBar
(= the bottom part of the ActionBar
)?