Android system UI tips for Surface Duo

In this article, we show how to control the status bar and navigation bar, or support full-screen display in your app.

Full screen

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if(hasFocus) {
        getWindow().getDecorView().setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

See the Android fullscreen doc for more information.

Status bar

See the Android documentation to dim or hide the status bar.

window.statusBarColor = Color.TRANSPARENT;

In styles.xml add these elements in the application theme:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

To set a color, the styles.xml should contain a color reference:

<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@color/colorPillBar</item>

which should exist in colors.xml (red in this case):

<color name="colorPillBar">#ff0000</color>

Red status bar

Tip

Apps share the status bar with the app on the other screen (except when spanned across both screens). Apps that request full-screen or otherwise manipulate the status bar will have those settings honored when they are spanned, or they are the active application on a single screen. When the app is on a single screen and the other screen gets focus, the focussed app's system UI settings will apply and the status bar may appear on the app which had requested full

Hide the navigation bar.

In styles.xml add these elements in the application theme:

<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>

To set a color, the styles.xml should contain a color reference:

<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">@color/colorPillBar</item>

which should exist in colors.xml (red in this case):

<color name="colorPillBar">#ff0000</color>

Red navigation bar