问题
My UI uses ABS with tabs (ActionBar.NAVIGATION_MODE_TABS
) and a bunch of fragment layouts being loaded for each tab.
There is one tab where I need to hide the ActionBar (to reclaim some screen space) for the UI but calling getSupportActionBar().hide();
would nuke the tabs along with the ActionBar.
I was wondering if there is was anyway at all where I could hide the actionbar without affecting the tabs?
EDIT: Actually, come to think of it, the Actionbar doesn't do anything except showing the app branding/icon. So I wouldn't mind hiding the ActionBar altogether and just showing the tabs.
回答1:
This is called a 'collapsed action bar'. It will be automatically hidden if you don't display the title and the home icon:
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
If you want to have both tabs and actions, you can use a split action bar and have the actions (menus) at the bottom.
来源:https://stackoverflow.com/questions/12928092/actionbarsherlock-hide-actionbar-while-displaying-tabs