This has been asked many times: How to hide status bar permanently in android? Android ICS hide System bar Hide permanent system Bar Android But most of the times answers dont work or only hide until the users swips with his finger.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
This resolves into the application crashing.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
This hides it temporarily.
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Setting the systemUIVisiblity has exactly the same effect.
val windowInsetsController =
ViewCompat.getWindowInsetsController(window.decorView) ?: return
// Configure the behavior of the hidden system bars
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// Hide both the status bar and the navigation bar
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
This does not seem to be doing anything, but if it would, it would probably also just hide until the swipe.
If have tried calling these code blocks repeatively on different events:
val screenText : TextView = findViewById(R.id.textView5);
screenText.setOnClickListener {
hideSystemUI()
}
Creating a TextView and calling the code blocks on click.
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
hideSystemUI()
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
}
}
This code snippet from https://developer.android.com/training/system-ui/visibility
But these work hacky, and if you are fast you can still expand the status bar. The navigation bar will always appear after swiping.
Why do I want to make these bars disappear? Because I am writing a launcher. It should look similar to the Samsung Kids. The user should be prohibited to change anything in the system settings until some password is given in. How would one do that with these limitations?