2

I have seen two ways to disable the status bar. Both of them are deprecated.

The first one from the documentation:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

The other one from here, for example:

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

In the first method setSystemUiVisibility is deprecated, and in the second method WindowManager.LayoutParams.FLAG_FULLSCREEN is deprecated. What is a non-deprecated/current way to hide the status bar on android? I'd prefer a method which hides the status bar throughout the app, not just in one activity.

Huzaifa
  • 482
  • 1
  • 7
  • 20

1 Answers1

1

You could use this:

FrameLayout frameLayout = findViewById<FrameLayout>(R.id.mainView)
frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)

for the new android version, where R.id.mainView is your main layout. Please check this for more details: https://proandroiddev.com/exploring-windowinsets-on-android-11-a80cf8fe19be

benjiii
  • 413
  • 3
  • 9
  • 1
    Thanks. For anyone else reading this, the non-deprecated method is `getWindow().setDecorFitsSystemWindows(false)`, but you can't use it unless your minSDK is Android R. – Huzaifa Sep 15 '20 at 16:52
  • @HuzaifaHussain setSystemBarsAppearance what about this? – Sandrin Joy Sep 15 '20 at 16:55