Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How can I make the status bar / navigation bar invisible on Android, while keeping the padding at the top / bottom of the screen in android ?

By M.K. Verma · 4 May 2022

How can I make the status bar / navigation bar invisible on Android, while keeping the padding at the top / bottom of the screen in android ?

You can transparent the status bar

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

For hiding StatusBar

if (Build.VERSION.SDK_INT < 16) {
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
} else if (Build.VERSION.SDK_INT < 30) {
    window.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
    actionBar?.hide()
} else {
    window.decorView.windowInsetsController?.hide(WindowInsets.Type.statusBars())
}