5

i have some problem to hide status and navigation bar in app.

Assumptions:

  • use lib com.google.android.material:material:1.1.0-alpha10
  • use style Theme.MaterialComponents.Light.NoActionBar

Solutions like

window.apply {
      clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
       addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
        } else {
            decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        }
        statusBarColor = Color.TRANSPARENT
}

Doesn't work properly

Skalaw
  • 96
  • 3
  • 7

1 Answers1

4
  1. Create new theme in styles.xml:
 <style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="android:windowBackground">@color/white</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="windowNoTitle">true</item>
</style>
  1. Apply this theme in Manifest (for desired activity)
<activity
    android:name=".SearchActivity"
    android:label="Text"
    android:theme="@style/AppTheme.NoActionBar" />
Simon
  • 1,657
  • 11
  • 16