Most of the android applications show the status bar while running the app. Some of the apps need full screen and they hide the status bar. Mainly android games hide the status bar because they need more space. If you don’t want to show android status bar in your application, this tutorial teaches you to hide and show android status bar/notification bar programmatically.

Status bar can be hidden with different ways, using java code and setting the activity theme in your app styles.xml or AndroidManifest.xml file.

Hide and Show Android ActionBar in Any Activity
Android Toolbar Example: How to Use Toolbar as ActionBar
How to Disable Screen Orientation Change in Android Programmatically

Android Example: Hiding Android StatusBar/NotificationBar Programmatically

Following are the two different methods to hide android status bar programmatically.


Method 1: Hiding Android StatusBar Using Java Code

Following is the code of java activity file and XML layout file to hide and show status bar/ notification bar.

XML Layout File

res/layout/ hide-show-notification-bar-android.xml

Java Activity File

src/ HideShowStatusBar.java

If you are going to hide status bar at runtime you can add getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); before setContentView of onCreate method.

Method 2: Hiding Android Status Bar Using Theme Setting

You can also hide android status bar/ notification bar on android 4.0 (API level 14) and lower using theme setting. Following is the code of res/values/styles.xml file. You can also set theme directly from AndroidManifest.xml file and this is also hide your app actionbar/appbar.


Now, run your How to Hide and Show Android Status Bar Programmatically application, status bar is disabled now.

Post a Comment

Powered by Blogger.