Reputation: 532
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.
Upvotes: 2
Views: 3499
Reputation: 553
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
Upvotes: 1