How to hide the status bar?

How can I hide the status bar for a specific action?

I found this similar question, but none of the answers worked for me. The application just crashed every time I tried to switch to activity: How to hide the status bar in Android

Thanks.

+9
android android-activity android-statusbar
source share
5 answers

Try this operation before setting content.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
+19
source share

Hide status bar on Android 4.0 and below

  • By setting the application theme in the manifest.xml file.

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

    OR

  • When writing JAVA code in action, the onCreate () method.

     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If the Android version is lower than Jellybean, use this call to hide // the status bar. if (Build.VERSION.SDK_INT < 16) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } setContentView(R.layout.activity_main); } 

Hide status bar on Android 4.1 and higher

By writing JAVA code to the Activity onCreate () method.

 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(); 
+3
source share
 if (Build.VERSION.SDK_INT < 16)//before Jelly Bean Versions { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else // Jelly Bean and up { View decorView = getWindow().getDecorView(); // Hide the status bar. int ui = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(ui); //Hide actionbar ActionBar actionBar = getActionBar(); actionBar.hide(); } 
+1
source share

Open styles.xml and update the styles that your activity uses:

 <style name="ExampleTheme" parent="android:Theme.Light"> <item name="android:windowNoTitle">true</item> <!-- add this line --> </style> 
0
source share

The only working answer (for me at least)

In styles.xml

 <resources> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> ... </style> </resources> 

The solution in the code does not work for me in 4.4.2 Kitkat.

0
source share

All Articles