android - windowSplashScreenAnimatableIcon not found
问题描述
I want to customize my splash screen on Android 12 and I get the AAPT error:
AAPT: error: style attribute 'android:attr/windowSplashScreenAnimatableIcon' not found.
Here is the relevant part of the style:
<style name="SplashTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowSplashScreenAnimatableIcon">@drawable/ic_splash</item>
</style>
That is the attribute mentioned in the documentation.
Here is an overview of the build tool libs I'm using:
compileSdk="android-S"
minSdk=21
targetSdk="S"
buildTools='31.0.0-rc4'
I use Android Studio Arctic Fox | 2020.3.1 Beta 1 just for the records.
Can someone point out what I'm doing wrong?
解决方案
It seems that the documentation is wrong/outdated. The right attribute is:
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>
The correct attribute is listed in the R.attr
class.
In a previous version of this answer I had a way to keep the splashscreen working as before, however this does not work anymore.
Today I suggest to use the splash compat library and this style:
<style name="SplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/ic_launcher_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="postSplashScreenTheme">@style/Your.Normal.Theme</item>
</style>
This has the two assumptions that you use a adaptive launcher icon with the default namings. In my case ic_launcher_background
is a solid color this is why I'm using color instead of drawable prefix. I hope that helps others.
Here is the guide for the splash migration from Google.
推荐阅读
- ios - 使用 Swift IOS 打开特定专辑
- javascript - 在单个页面中处理多个电子邮件 HTML
- php - Xampp 和 live Host 上的登录都停止工作,但之前可以工作
- spring-boot - 使用页面(可分页)springboot后无法提取结果集
- hibernate - 当我将十进制值添加到始终加密的数据库中时,它显示错误
- html - 媒体查询不适用于不同的屏幕
- java - Spark-Java:连接聚合 groupBy 的结果
- java - 如何使用运行时在java中调用python程序
- dotcms - 未找到 Dotcms 详细信息页面
- ios - 跨应用重新访问相同的 UIViewController