I'm having this strange behavior with the action ActionBar Tabs showing above the ActionBar. This happens to be happening when I am setting a custom view for the ActionBar.I'm implementing the Done-Discard pattern using Roman Nurik's example here
This is happening due to the masking of ActionBar.DISPLAY_SHOW_HOME in setDisplayOptions()
final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(
ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
The screen looks like this:
But when I dont mask the ActionBar.DISPLAY_SHOW_HOME it works fine but the App Logo is displayed. like this.
This seems to be a bug.Please suggest a fix.I don't want the logo to be displayed.
Solution here:
ActionBarSherlock - Tabs appearing ABOVE actionbar with custom view
and here: https://github.com/JakeWharton/ActionBarSherlock/issues/327
This seems a little hacky to me but here's the workaround: Add this piece of code in your onCreate and hide the Home Icon. Now the ActionBar and Tabs work as expected.
Remember not to Disable/Mask the DISPLAY_HOME_HOME in the ActionBar.setDisplayOptions().This will not work if you mask/disable it.
View homeIcon = findViewById(android.R.id.home);
((View) homeIcon.getParent()).setVisibility(View.GONE);