Loading...

Hide and Show Android ActionBar in Any Activity

ActionBar is one of the most important UI elements in android application. Action bar is also known as app bar. Android action bar is displayed by default with the AppCompat library and android SDK 3.3.0. Most of the developers use ActionBar in their app but not compulsorily in every app. So in this example, I am going to show you how to hide and show action bar in android app by programmatically and using XML.

ActionBar/AppBar can be hid with different method by busing java code and AndroidManifest.xml file. Following are the different ways to hide android action bar. While implementing splash screen, it becomes better hiding ActionBar.

Related:
Android Material Design ActionBar/App Bar: How to Make Custom ActionBar
Android Toolbar Example: How to Use Toolbar as ActionBar
Android Action Bar Tutorial and Example With Option Menu

Android Example: How to Show and Hide Android ActionBar on Certain Activities


Following are the different method to hide and show android action bar/app bar programmatically and using XML.

Method 1: Hide and Show ActionBar Programmatically


For hiding actionbar in android 2.1 and higher device programmatically you should import android.support.v7.app.ActionBarActivity package and use .hide() to hide actionbar and .show() to show actionbar. Following is the example code.

Src/ AndroidActionBarHideShow.java

For hiding ActionBar in Android 3.0 and higher, you don’t need to import support ActionBar package just use import android.app.ActionBar package then use .show() and .hide() to show and hide android actionbar respectively. Following is the example code to hide android actionbar without using support package.

Src/ AndroidActionBarHideShow.java


Method 2: Hide and Show ActionBar Using .NoActionBar Theme


You can also hide your application app bar using .NoActionBar theme. Following is the sample example where I have used Theme.AppCompat.Light.NoActionBar to hide app bar.

Res/values/styles.xml

Android Example: How to Show and Hide Android ActionBar on Certain Activities

Above are the different ways to hide and show android ActionBar programmatically and using XML. Now, run your Hide and Show Android ActionBar in Any Activity application there will be no ActionBar.
XML 8070507209905374902
Home item