How do I stretch a Fragment's layout to fill the screen while in Immersive Sticky Mode?
android, android-fragments
Solution
The culprit was `android:fitsSystemWindows="true"` in the Activity's layout. After I removed it the fragment expanded to take up the entire window.
Problem
I'm having an issue with my fragment's layout in Immersive Sticky Mode. The system bar and navigation bar are disappearing correctly, but the Fragment layout doesn't stretch to fill in the spaces those bars previously occupied. Here's a screenshot showing off what I'm talking about: The red is the Activity's background, and the blue is the Fragment's. And here's how I'm starting up Immersive Sticky Mode (from the Activity, just before it loads the Fragment): ``` public void startImmersiveMode() { 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 | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } ``` How do I get the Fragment to expand to cover the Activity? Edit - Here's some XML: Activity: ``` <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:background="@color/red"/> ``` Fragment: ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container_view" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/holo_blue_bright" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World"/> </LinearLayout> ```