4

I'm setting up a simple view which just contains an empty RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:clipToPadding="false"
    android:background="@color/red"/>

Using this theme:

<style name="FullscreenTheme" parent="BaseTheme">
    <item name="android:textColorSecondary">@android:color/white</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:navigationBarColor">@android:color/transparent</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

And this in onCreate:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

This results in the intended effect:

enter image description here

However, when I try to add a child, I can't get it to do the same thing. The XML looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:clipToPadding="false"
    android:background="@color/red">

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bit_teal"
        android:fitsSystemWindows="true"
        android:clipToPadding="false"/>

</RelativeLayout>

And here is what it looks like:

enter image description here

Any ideas?

JMRboosties
  • 15,500
  • 20
  • 76
  • 116

1 Answers1

1

get rid of android:fitsSystemWindows="true" from the RelativeLayout. I don't think that both can fit the system view at the same time, and the parent will always have the precedence to the child(ren)

Blackbelt
  • 156,034
  • 29
  • 297
  • 305