Search code examples
androidtabsandroid-actionbarappbar

Android hide Actionbar show only the tabs


I want to show the tabs on the top, and hide the actionbar.

Only the parts in the red rectangle, and hide the empty row above them.

I used these lines to hide the icon, and the title on the actionbar:

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

Any suggestions what to do to have only the tabs in my app?


Solution

  • If you want to hide it in the code. You may also need to remove onCreateOptionsMenu you are using that (For example).

    public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
    }
    

    Also add the following line in on create.

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