4

How to hide status bar (phone icon,battery icon, network icon etc.) in android?

Confuse
  • 5,336
  • 6
  • 33
  • 57
user3168129
  • 151
  • 1
  • 2
  • 6

4 Answers4

4

Write this code just above setContentView(R.id.activity_main) and it will work.

requestWindowFeature(Window.FEATURE_NO_TITLE);     
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Sagar Pilkhwal
  • 5,914
  • 2
  • 27
  • 78
Nithin
  • 528
  • 4
  • 19
2

You can also change theme in Android Manifest to hide the status bar such that you don't have to call the code in every activity.

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    ...
</application>

If you are not using Holo, you may need to change that slightly.

Alternatively, you can call this code in each activity -

For 4.0 and Lower

Add this in onCreate method before setContentView(R.layout.activity_main); line.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

For 4.1 and higher

View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Confuse
  • 5,336
  • 6
  • 33
  • 57
1
// Hide status bar
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Show status bar
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Documentation for System-UI Status

Hide the Status Bar on Android 4.1 and Higher:

View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
Sagar Pilkhwal
  • 5,914
  • 2
  • 27
  • 78
1

In your manifest you can add android:theme="@android:style/Theme.NoTitleBar".

In your Activity you can add getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Hope this will help you in finding your solution.