Let's customize the Splash Screen of a MAUI app

I am a passionate mobile app and software developer with a focus on C# .NET, Xamarin.Forms and .NET MAUI.
Search for a command to run...

I am a passionate mobile app and software developer with a focus on C# .NET, Xamarin.Forms and .NET MAUI.
I tried the approach with .Net 7 on MAUI to support light and dark mode for splash screen with following steps but it doesn't seem to work as per following:
<MauiSplashScreen Include="Resources\Splash\splash.svg"/>
The "@color/colorPrimaryDark" for "styles.xml" in both "values" and "values-night" takes the value #1B3147 for bacground color of splash screen and not what I have mentioned in "colors.xml".
Here is the configuration of "MainActivity.cs":
[Activity(Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.KeyboardHidden, ScreenOrientation = ScreenOrientation.Portrait)]
So, please let me know what I am missing on my side to make it work. Awaiting you reply.
Thanks Julian for sharing this article. I find it really useful!
For the transparent background of the image in the <MauiSplashScreen> have you tried? #00FFFFFF
It is just curiosity if the ALPHA HEX works :)
I'm happy that you find it useful ☺️
Indeed, I've tried that and if I remember correctly, the background was completely black then, but in both configurations. Not quite sure anymore, though.
Introduction In .NET MAUI, we sometimes face the situation that we would like to evaluate a specific value, e.g. a property from a child object, against some logic from the ViewModel. I personally sometimes wish it were possible to bind directly to a...

A starting point for customized client apps using a single code base

Introduction Social media apps like Instagram use full-page scrollable video controls called "reels" (named after the device used to store film - or garden hoses) which allow the user to swipe or scroll up and down in order to switch between videos (...

The next step in simplified route management for .NET

How to avoid navigation hell by having Routes auto-generated for you

A custom company or app logo that shows up while an app is starting is a nice eye catcher and helps with strengthening the recognition of a brand. In this blog post I want to show you how you can easily modify the splash screen which comes already prepared with new MAUI app projects with your own logo and background.
In the past, apps would show complex graphics or fancy animations on the splash screen. With the advent of newer mobile operating system versions, especially since Android 12.0, mobile app developers have less options for the customization of the splash screen of an app, at least for simple scenarios.
For the purpose of a unified look and feel, the splash screen should be simple and feature only a custom logo and a simple background. Modern apps have relatively low start up latencies, so that the splash screen will not be visible for a long time anyway. Therefore, I will only focus on adding a custom logo and background color, advanced scenarios including animations and splash screen activities won't be covered.
However, as an extra goody, I will show you how to change the theme of the splash screen based on the system theme on Android.
Note: Starting with Android 12.0, the splash screen icon will be displayed inside a circular frame and everything outside that frame will be hidden by a mask. For more on this, please refer to the official documentation.
This is what the default splash screen of the MAUI app template project looks like:
The logo and background color are defined in the .csproj file of your MAUI app project. You can edit the file by right-clicking on the project and selecting "Edit Project File". Then scroll down to the <PropertyGroup> that contains the following:
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
In order to add your own logo, the only thing you need to do is replace the splash.svg with your own logo. As an example, we will just use the dotnet-bot.svg which comes with the template, but we give it a different name, e.g. mysplashscreen.svg:
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\mysplashscreen.svg" Color="#512BD4" BaseSize="128,128" />
Important: The logo should be square and with a transparent background for best results.
Note: At the time of writing, there is an issue with the one of the build actions of MAUI, which requires giving the splash screen image a completely new name each time it is changed. This will be fixed in a future release.
Now, we just need to change the background color of the splash screen to make it look great:
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\mysplash.svg" Color="#000000" BaseSize="128,128" />
Pretty cool, we now have a custom splash screen that works on Android and iOS:

On Android, there is a little trick on how to go even a step further and change the background color (and status bar theme) for the splash screen depending on the selected system theme. For this, we can take advantage of the night mode feature to show the black background only for dark mode and a white background for white mode, which is a neat little extra.
In your MAUI project, navigate to the Platforms/Android/Resources/ folder and, if not present yet, add a values subfolder. In this folder, create two files (or edit the existing ones):
Attention: The styles.xml actually probably already exists and is simply hidden from the project. If so, right-click on the values folder and select Add -> Existing Item and then select the styles.xml file in that location.
Then, in your colors.xml define some colors, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#c2c2c2</color>
<color name="colorPrimaryDark">#ffffff</color>
<color name="colorAccent">#3c3c3c</color>
</resources>
Next, create your own Theme in the styles.xml, inherit from Maui.SplashTheme and set your color for the android:windowSplashScreenBackground item:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="Maui.SplashTheme">
<item name="android:windowSplashScreenBackground">@color/colorPrimaryDark</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
This will set up your splash screen color when the user is using the Light theme of Android.
For Dark theme, you need to do essentially the same as for the Light theme, with a small difference.
In your MAUI project, add the following subfolder: Platforms/Android/Resources/values-night (note the -night suffix). In this folder, again create the two files:
In your colors.xml define some colors, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#c2c2c2</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#c2c2c2</color>
</resources>
Again, create your own Theme in the styles.xml, inherit from Maui.SplashTheme and set your color for the android:windowSplashScreenBackground item:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="Maui.SplashTheme">
<item name="android:windowSplashScreenBackground">@color/colorPrimaryDark</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
This will set up your splash screen color when the user is using the Dark theme of Android.
When you're done, your folder structure should look something like this:
Finally, we still need to apply our custom theme to our MainActivity like this:
[Activity(Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity { }

Note: The background color of the image can only be set once in the <MauiSplashScreen> build action and therefore is not adaptive, unfortunately. Notice the round image mask on Android as described in the beginning, as well.

Setting up a simple splash screen is very easy with .NET MAUI, because the <MauiSplashScreen> build action pretty much does all the work for you as it automatically generates everything for you. Unlike Xamarin.Forms, there is no need to create your own storyboard for iOS, for example, anymore.
If you enjoyed this blog post, you may want to follow me on LinkedIn, subscribe to this blog and star the GitHub repository for this post.