4

With the new android 12 splash screen migration the following is required.

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

SRI
  • 41
  • 1
  • 5

1 Answers1

1

The official document had reminded the developers to use the Androidx SplashScreen compat library to do the splash screen in the Android <= 11.

But it also has some limitations:

  1. icon animation is not supported -- AnimatedVectorDrawable
  2. icon background is not supported -- IconBackgroundColor
  3. brand logo is not supported -- BrandingImage

The link about the SplashScreen compat library: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.

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

Furthermore, you need to set the theme in the <application> and <Mainacticvity>. Such as:

<application android:theme="@style/AppTheme"></application>
[Activity(Label = "@string/app_name", Theme = "@style/Theme.App.Starting", MainLauncher = true)]
Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14
  • I am confused, if you look at my style, I am already using '@android:color/white' I am not using the color white but I am using a color. I dont understand what you're saying above, that is the exact documentation I used, you can see in my style I already have the one you said to use, yet in Android <= 11 the background is white not black. – SRI Apr 28 '22 at 17:28
  • Also I noticed if I change the phone theme to light then the splash background is white...if I change the theme to dark then the background is black. All I am wondering is now to get the splash background in Android <= 11 to black and not white. I have the tag in my style you said to use and its not working...works for Android 12 though. Also I followed the documentation you sent, thats how I migrated my app and got the style. – SRI Apr 28 '22 at 17:38
  • – SRI Apr 28 '22 at 17:45
  • The `windowSplashScreenBrandingImage` is not support in the Android <= 11. And you can check the the answer I had edited. In addition, did you called the `installSplashScreen()` before the `SetContentView()`?@SRI – Liyun Zhang - MSFT Apr 29 '22 at 07:36
  • For all of you out there that made this mistake in your style this is the correct format '''@android:color/black''' this will cause the splash background color to default to the the phones selected theme light/dark '''@android:color/black''' I am not sure where I got the later from, there is another article on it here https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying – SRI Apr 30 '22 at 00:14
  • So it works correctly now?@SRI – Liyun Zhang - MSFT May 03 '22 at 06:07
  • @Zhang yes it works correct, the issue was the prepended 'android' in the tag. Some of the tags in the style require and it and some don't. Visual Studio will automatically prepend the tag with intellisense. There are multiple threads out there that show the style tag with 'android:' appended but it should not be. – SRI May 04 '22 at 13:00