How to hide/show action bar programatically? [SOLVED] – Android Studio


To Hide/Show the action bar of your activity on Android Devices with API>11, just use the following codes:

To Hide the action bar:

getSupportActionBar().hide();
// If your minSdkVersion is 11 or higher, instead use:
//getActionBar().hide();

You can add the code inside the onCreate method if you don’t want the action bar to be shown at all, or if you want it to happen at the click of a button then you can paste it inside the OnClickListener of the button.

To Show the action bar:

getSupportActionBar().show();
// If your minSdkVersion is 11 or higher, instead use:
//getActionBar().show();

PhD researcher at Friedrich-Schiller University Jena, Germany. I'm a physicist specializing in theoretical, computational and experimental condensed matter physics. I like to develop Physics related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.



Leave a Reply

Your email address will not be published. Required fields are marked *