Skip to content

Commit

Permalink
[android] fix MauiSplashScreen on Android 12+ (#8394)
Browse files Browse the repository at this point in the history
Fixes: #7404
Context: https://developer.android.com/guide/topics/ui/splash-screen#set-theme

Reviewing a lot of the feedback around splash screens, I tried:

1. Rename `splash.svg` to `splash2.svg`
2. Change the .NET splash logo from white to blank.

I found these changes worked fine on Android < 12, but I did not see
my changes on Android 12+!

This was more troubling when I changed the `MauiSplashScreen` `Color`
to white.

After some review, it looks like we need to define:

    <item name="android:windowSplashScreenBackground">@color/maui_splash_color</item>
    <item name="android:windowSplashScreenAnimatedIcon">@drawable/maui_splash</item>

With these changes in place, the splash screen is working for me in
Android 12+.

I believe we implemented `MauiSplashScreen` while Android 12 was still
in beta, so we just didn't notice this behavior. We also were sharing
the same `.svg` file for the app icon and splash screen previously,
which may have confused or hidden this issue.
  • Loading branch information
jonathanpeppers authored Jul 3, 2022
1 parent 2d1e763 commit 873db6c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Core/src/Platform/Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<style name="Maui.SplashTheme" parent="Maui.MainTheme.NoActionBar">
<item name="maui_splash">true</item>
<item name="android:windowBackground">@drawable/maui_splash</item>
<!--
Android 12+ specific settings
See: https://developer.android.com/guide/topics/ui/splash-screen#set-theme
-->
<item name="android:windowSplashScreenBackground">@color/maui_splash_color</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/maui_splash</item>
</style>

<!-- Themes for Xamarin.Forms backwards compatibility -->
Expand Down

0 comments on commit 873db6c

Please sign in to comment.