Android Splash Screen API incorrect logo for API versions less than 31

971 views Asked by At

I'm trying to implement the new Splash API.

I created a theme

<style name="Theme.CustomSplashScreenTheme" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/primary1BlueDefault</item>
    <item name="postSplashScreenTheme">@style/AppTheme</item>
</style>

Added the theme to manifest

<application
    android:name=".App"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="${appLabel}"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.CustomSplashScreenTheme">

And enabled in the activity

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    installSplashScreen()
    setContentView(R.layout.activity_main)
    if (savedInstanceState == null) {
        replaceFragment(MainFragment.newInstance(), R.id.container)
    }
}

As result, it works for android 12 enter image description here

But for android less than 12 an incorrect icon is being shown

enter image description here

1

There are 1 answers

0
bryanless On

You need to specify windowSplashScreenAnimatedIcon in your theme style for SDK 30 and lower such as:

<style name="Theme.CustomSplashScreenTheme" parent="Theme.SplashScreen">
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
    <item name="windowSplashScreenBackground">@color/primary1BlueDefault</item>
    <item name="postSplashScreenTheme">@style/AppTheme</item>
</style>

SplashScreen documentation