Reputation: 35
I am using "Navigation Drawer Activity" template from latest Android Studio (2021.2.1 Patch 2) as a start.
How can I hide navigation bar completely? Following code only hides the buttons but navigation bar's white background still exists.
View decorView = getWindow().getDecorView();
int uiOptions = SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Thanks.
Upvotes: 0
Views: 782
Reputation: 35
java version:
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
getWindow().getInsetsController().hide(WindowInsetsCompat.Type.systemBars());
Upvotes: 1
Reputation: 701
Apply this code in onCreate()
of your activity :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (window != null) {
window.decorView.windowInsetsController!!.hide(WindowInsets.Type.statusBars())
window.decorView.windowInsetsController!!.hide(
WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()
)
}
} else {
val decorView = window.decorView
val uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
decorView.systemUiVisibility = uiOptions
}
Upvotes: 0