Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 699
DanMan Avatar asked Nov 15 '25 10:11

DanMan


1 Answers

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

like image 188
bryanless Avatar answered Nov 17 '25 08:11

bryanless



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!