4

With my most recent app, I've decided to use Conductor for the whole of the navigation. It's a single activity app, and everything works fine, except for the splash screen - for some reason, the initial controller refuses to stretch under the status bar, even though the main layout and the controller host are both CoordinatorLayouts with appropriate fitsSystemWindows flags.

The host activity:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <variable
            name="viewModel"
            type="net.fonix232.app.viewmodel.MainViewModel" />
    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:attr/windowBackground"
        android:fitsSystemWindows="true">

        <net.fonix232.app.common.ChangeHandlerCoordinatorLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</layout>

The splash controller's layout:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="viewModel"
            type="net.fonix232.app.viewmodel.SplashViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:attr/windowBackground"
        android:fitsSystemWindows="true">

        [... splash content ...]

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>

The screen after splash:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="viewModel"
            type="net.fonix232.app.viewmodel.SplashLandingViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:attr/windowBackground"
        android:fitsSystemWindows="true">

        [... splash landing content ...]

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

The first splash layout does not stretch the content (a custom image layer setup) under the status bar, however on the second splash (SplashLanding) screen, it is properly stretched - and since I use shared element transition, I get a nice image resize effect on the background as well.

Where is this going wrong?

fonix232
  • 2,132
  • 6
  • 39
  • 69

0 Answers0