3

I have trouble with hiding status bar on Android Q. When I hide it in split-view, it becomes white, instead of black. But if I'm not in split-view, everything is ok. How I do it:

public void hideSystemUI() {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
}

Is it just a bug or should I use some another way? I tried the way from official documentation, but it works terribly and the bar is white anyway.

NOTE: The problem it's white, not in that it's not hiding and only in split-screen mode. Fullscreen is not an option, I need to hide it dynamically. It's specific for Q only! It's not a duplicate. Please read carefully.

VolodymyrH
  • 1,927
  • 2
  • 18
  • 47

1 Answers1

1

@Abhinav's answer is correct, but if you want to go with the official documentation you should use setSystemUiVisibility(). Like this:

View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();

Also, set the theme in your styles.xml file, not in the manifest. Like this:

<item name="android:windowFullscreen">true</item>

Add this to your styles.

For more information check out this: https://developer.android.com/training/system-ui/status

If you still support API 16 and lower use @Abhinav's Code. It checks for both cases. If not then use the one listed here.

If you want to hide your toolbar try this code:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowFullscreen">true</item>
</style>

Paste this inside your styles.xml file. Or if you want Dark replace the Light with Dark and remove NoActionBar.

Gaurav Mall
  • 2,372
  • 1
  • 17
  • 33