简体   繁体   English

Android <= 11 初始屏幕背景颜色和品牌

[英]Android <= 11 Splash Screen Background Color and Branding

With the new android 12 splash screen migration the following is required.对于新的 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>

The issue is windowSplashScreenBackground and windowSplashScreenBrandingImage is not used by Android <= 11. So how do we get the background to be a specific color and also show the branding at the bottom?问题是 windowSplashScreenBackground 和 windowSplashScreenBrandingImage 没有被 Android <= 11 使用。那么我们如何让背景成为特定颜色并在底部显示品牌呢?

The official document had reminded the developers to use the Androidx SplashScreen compat library to do the splash screen in the Android <= 11.官方文档已经提醒开发者在Android <= 11时使用Androidx SplashScreen兼容库做闪屏。

But it also has some limitations:但它也有一些限制:

  1. icon animation is not supported -- AnimatedVectorDrawable不支持图标 animation -- AnimatedVectorDrawable
  2. icon background is not supported -- IconBackgroundColor不支持图标背景 -- IconBackgroundColor
  3. brand logo is not supported -- BrandingImage不支持品牌标识 -- BrandingImage

The link about the SplashScreen compat library: https://developer.android.google.cn/reference/kotlin/androidx/core/splashscreen/SplashScreen SplashScreen兼容库链接: https://developer.android.google.cn/reference/kotlin/androidx/core/splashscreen/SplashScreen

You can set the windowSplashScreenBackground in the Android <= 11 by the following code with the Androidx SplashScreen compat library.您可以通过以下代码使用 Androidx SplashScreen 兼容库将 windowSplashScreenBackground 设置为windowSplashScreenBackground <= 11。

<item name="windowSplashScreenBackground">@android:color/white</item>

In addition, the official document also sayed: Optionally, you can use windowSplashScreenBrandingImage to set an image to be shown at the bottom of the splash screen.此外,官方文档还说:可选地,您可以使用 windowSplashScreenBrandingImage 设置一个图像显示在启动画面的底部。 The design guidelines recommend against using a branding image.设计指南建议不要使用品牌形象。

If you need more information, please check the official document: https://developer.android.google.cn/guide/topics/ui/splash-screen/migrate and https://developer.android.com/guide/topics/ui/splash-screen如果您需要更多信息,请查看官方文档: https://developer.android.google.cn/guide/topics/ui/splash-screen/migratehttps://developer.android.com/guide/topics/用户界面/闪屏

Furthermore, you need to set the theme in the <application> and <Mainacticvity> .此外,您需要在<application><Mainacticvity>中设置主题。 Such as:如:

<application android:theme="@style/AppTheme"></application>
[Activity(Label = "@string/app_name", Theme = "@style/Theme.App.Starting", MainLauncher = true)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM