随着新的android 12启动屏幕的迁移,以下是必需的。
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/brand_logo</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>问题是windowSplashScreenBackground和windowSplashScreenBrandingImage不是安卓<= 11所使用的。那么,我们如何才能获得特定颜色的背景,同时在底部显示品牌呢?
发布于 2022-04-28 01:30:44
官方文件提醒开发人员使用Androidx SplashScreen compat库在Android <= 11中执行启动屏幕。
但它也有一些局限性:
不支持AnimatedVectorDrawable
关于SplashScreen compat库的链接:https://developer.android.google.cn/reference/kotlin/androidx/core/splashscreen/SplashScreen
您可以使用Androidx <= compat库通过下面的代码在Androidx<= 11中设置<=。
<item name="windowSplashScreenBackground">@android:color/white</item>此外,正式文档还可以选择sayed :可以使用windowSplashScreenBrandingImage设置在启动屏幕底部显示的图像。设计指南建议不要使用品牌形象。
如果您需要更多信息,请查看正式文档:https://developer.android.google.cn/guide/topics/ui/splash-screen/migrate和https://developer.android.com/guide/topics/ui/splash-screen
此外,您需要在<application>和<Mainacticvity>中设置主题。例如:
<application android:theme="@style/AppTheme"></application>
[Activity(Label = "@string/app_name", Theme = "@style/Theme.App.Starting", MainLauncher = true)]https://stackoverflow.com/questions/72031726
复制相似问题