Skip to content Skip to sidebar Skip to footer

Android: Hide Actionbar, Keep Tabs

To keep this simple: I have tabs in my actionbar, but the action bar take up too much space. I want that extra space. I need a way to hide the action bar, yet keep my tabs. Is ther

Solution 1:

You can have an empty Actionbar, then the tabs will occupy the space:

getSupportActionBar().setDisplayShowHomeEnabled(false);              
getSupportActionBar().setDisplayShowTitleEnabled(false);

Solution 2:

Try the below code:

finalActionBaractionBar= getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);

Also remove the below in code which is added default when project is created:

publicbooleanonCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.main, menu);
      returntrue;
}

Solution 3:

This did the trick for me

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

I also commented the line

getMenuInflater().inflate(R.menu.main, menu);

Solution 4:

Ahmad's answer is correct but it requires API 11. For supporting lower APIs, use this code -

setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

To enable it, use -

setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)

Post a Comment for "Android: Hide Actionbar, Keep Tabs"