I have a layout that transitions between 2 Scenes.
layout.xml
<FrameLayout
android:id="@+id/framelayout_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
// Some background views.
<FrameLayout
android:id="@+id/scene_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/scene_a" />
</FrameLayout>
</FrameLayout>
res/layouts/scene_a.xml
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
// Child views removed for brevity
</android.support.constraint.ConstraintLayout>
Scene B layout is identical.
In the activity, ViewCompat.setOnApplyWindowInsetsListener(frameLayout, (v, insets) -> insets);
is called to use fitsSystemWindows
with FrameLayout.
The views are correct on initial view inflation i.e views are drawn under the status bar, but content is pushed down by the window insets to avoid the status bar.
However, when I transition to Scene B, that padding provided by fitsSystemWindows is lost and the content jumps up. Scene A loses the padding too, when returning.
Any assistance greatly appreciated with how to keep this padding through the transitions.