Is there a way to use a layout instead of an animated icon/icon for splash screen?

Viewed 52

Was migrating my app to the newish splash screen: https://developer.android.com/guide/topics/ui/splash-screen

And it works, except that in my app, if I launch it from a kill state, it will show a static icon, or an animated icon. I have a basic layout with a simple animation, but it isn't that easy to translate that into 1 big animated icon. Is there a way to show just the layout? Here is what I have now:

class SplashActivity: AppCompatActivity() {

private lateinit var binding: ActivitySplashBinding

override fun onCreate(savedInstanceState: Bundle?) {
    val splashScreen = installSplashScreen()
    super.onCreate(savedInstanceState)

    splashScreen.setKeepOnScreenCondition { false }

    binding = ActivitySplashBinding.inflate(layoutInflater)
    setContentView(binding.root)

    launchMainActivity()
}

private fun launchMainActivity() {
    lifecycleScope.launchWhenStarted {
        delay(SPLASH_DURATION_MS)

        val intent = Intent(this@SplashActivity, MainActivity::class.java)
        startActivity(intent)
        finish()
    }
}

}

Manifest

    <activity
        android:name=".SplashActivity"
        android:exported="true"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.App.Starting">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Theme

    <style name="Theme.App.Starting" parent="Theme.SplashScreen">
        <item name="windowSplashScreenBackground">@color/white</item>

        <item name="windowSplashScreenAnimatedIcon">@drawable/ic_logo</item>


        <item name="postSplashScreenTheme">@style/Theme.App.NoActionBar</item>
    </style>

It seems that if I don't specify windowSplashScreenAnimatedIcon, it just used my default launcher icon. I can't feed in a layout into this obviously. It is just annoying because my real splash screen comes after this launcher icon, so ~3s of launcher screen turns into closer to ~6s making my app look artificially slower. I could remove the splash screen I have developed, but that sort of defeats the purpose of using this at all for me.

Advice?

0 Answers
Related