这是我的style.xml的内容
@颜色/背景 @颜色/背景 This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@color/background</item>
</style>
我收到以下错误:
未找到样式属性“android:attr/windowSplashScreenIconBackground”。
如果我尝试按照Android 12 Splash Screen中的图标背景颜色不起作用中给出的建议扩展Theme.SplashScreen.IconBackground,则父类(指定为parent =“@ android:style / Theme.SplashScreen.IconBackground” )未识别并且也出现错误,例如:
未找到样式属性“android:attr/windowSplashScreenIconBackground”。
请不要建议 flutter_native_splash 包,它不起作用。我的 minSDK = 31,targetSDK = 34。
使用以下 style.xml,我可以根据自己的意愿更改背景颜色,但我得到的是白色图标背景颜色,我需要将其更改为背景颜色。
@颜色/背景 @颜色/背景 This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@color/background</item>
</style>
这是启动屏幕的截图
要更改 Flutter 中启动屏幕图标的背景颜色,您必须在 styles.xml 文件中定义“自定义主题”。
但是,标准 flutter 主题或 XML 样式不直接支持更改启动屏幕图标本身的背景颜色。图标的背景颜色由系统控制,可能会受到主题或系统设置的影响。
如果您的目标是 Android 12 (SDK 31+),请尝试通过定义在此处扩展的自定义主题来自定义启动屏幕外观,包括图标背景颜色 >> Theme.SplashScreen.IconBackground。
据我所知,没有内置的 Flutter 解决方案可以直接更改启动屏幕的背景,而无需诉诸特定于平台的自定义。你检查了 flutter_native_splash 包了吗?
或者您可以通过 littiefiles (lottiefiles.com) 创建动态风格的图像。这帮助我跳过了许多造型问题。