Android启动画面API在低于31的API版本中显示不正确的标志。

4

我正在尝试实现新的Splash API。

我创建了一个主题。

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

将主题添加到清单中

<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">

并在活动中启用

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

因此,它适用于Android 12。

但是在Android 12以下版本中,将显示错误的图标。

enter image description here

enter image description here


检查各个mipmap资源文件夹中的所有其他变体的启动器图标。用更新的标志替换它们。 - Alexander Hoffmann
你解决了吗? - Sohel Shaikh
1个回答

2
您需要在SDK 30及以下的主题样式中指定windowSplashScreenAnimatedIcon,例如:
<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>

启动屏文档


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接