找不到windowSplashScreenAnimatableIcon [英] windowSplashScreenAnimatableIcon not found

查看:24
本文介绍了找不到windowSplashScreenAnimatableIcon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android 12上自定义闪屏,但收到AAPT错误:

AAPT: error: style attribute 'android:attr/windowSplashScreenAnimatableIcon' not found.

以下是该风格的相关部分:

<style name="SplashTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:windowSplashScreenAnimatableIcon">@drawable/ic_splash</item>
</style>

这是documentation中提到的属性。

以下是我正在使用的生成工具库的概述:

compileSdk="android-S"
minSdk=21
targetSdk="S"
buildTools='31.0.0-rc4'

我使用Android Studio北极狐|2020.3.1测试版1只是为了记录。

有人能指出我做错了什么吗?

推荐答案

文档似乎有误/过时。正确的属性是:

<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>

R.attr class中列出了正确的属性。


在此答案的上一个版本中,我有一种方法可以保持闪屏像以前一样工作,但这不再起作用。

今天我建议使用Splash Compat库和这种风格:

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

这有两个假设,即您使用带有默认名称的自适应启动器图标。在我的例子中,ic_launcher_background是纯色,这就是我使用颜色而不是可绘制前缀的原因。我希望这能帮助其他人。

以下是Google提供的splash migration指南。

这篇关于找不到windowSplashScreenAnimatableIcon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆