Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding the title of an actionbar doesn't work on older versions of Android (using ActionBarSherlock)

I am trying to hide the title part of my actionbar using ActionBarSherlock like in the second picture: enter image description here

Setting:

actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);

works for versions >3.0 but doesn't work on older versions. A black space remains over the tab bar.

Is there a workaround to solve that issue?

like image 369
Romain Piel Avatar asked Feb 09 '12 11:02

Romain Piel


1 Answers

This feature is only available in ActionBarSherlock 4.0 which is currently in beta stage. You can find a link to the betas on actionbarsherlock.com.

There is a demo for precisely what you are trying to accomplish in the samples for 4.0.

public class TabNavigationCollapsed extends SherlockActivity implements ActionBar.TabListener {
    @Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar ab = getSupportActionBar();

        //The following two options trigger the collapsing of the main action bar view.
        ab.setDisplayShowHomeEnabled(false);
        ab.setDisplayShowTitleEnabled(false);

        ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        ab.addTab(ab.newTab().setText("Tab 1").setTabListener(this));
        ab.addTab(ab.newTab().setText("Tab 2").setTabListener(this));
        ab.addTab(ab.newTab().setText("Tab 3").setTabListener(this));
    }

    @Override public void onTabReselected(Tab tab) {}
    @Override public void onTabSelected(Tab tab) {}
    @Override public void onTabUnselected(Tab tab) {}
}
like image 81
Jake Wharton Avatar answered Oct 21 '22 22:10

Jake Wharton