Android Splash Screen Logos and Animations with Xamarin

Android 12 has a few surprises for mobile developers, and its new splash screen is one of the most notorious. In previous versions of the SDK, you needed to create an activity if you wanted to customize the splash screen. However, we now have access to the splash screen API to customize the screen. You can read more about it here and here.

In this post I will show Xamarin mobile developers how to use the new properties to include an icon on the splash screen. Also, I will demonstrate how to perform a basic animation on the splash screen so we can test out this new feature.

Android Icon and Resources

First, we need the appropriate images set in the app. You can use the default Xamarin.Forms icons, but I’ll use Trailhead’s logo :). I’ll begin by replacing the icons. I’m using IconKitchen to generate all the files for every screen size quickly:

Best tool ever!

Download the zip file, and after you are done replacing the resources, your solution should look something like this:

Note I’ve replaced the default icon with ic_launcher.xml.

Now, there are additional changes we need to make. In our style.xml file, we need to define the splash screen properties for our theme:

Updating the MainTheme style

“windowSplashScreenBackground” is the background color for the splash screen. It will attempt to calculate it from “windowBackground” if we don’t set it.

“windowSplashScreenAnimatedIcon” is what interests us in this example. It replaces an icon in the center of the starting window. If the object is animated and drawable, it will also play the animation while showing the starting window.

Remember, these values only work for the API level 31 or newer and will be ignored on older versions.

So far, so good.

Android Animation

Now, let’s get into the more complicated part. You can perform the animation with a png, but I would advise against it because animations usually transform and distort the content and you might not get the desired result. Different-sized PNGs were meant to be used in earlier versions of Android when nobody knew how many screen sizes manufacturers would create. SVGs are the safest option here because it won’t matter on which screen it’s drawn; it will scale to fit it perfectly.

Having said that. If you don’t have an SVG file, you can either ask your local designer to create one, or you can use FreeConvert to generate one (you might need to clean the result a bit, though).

The Android splash screen dimensions follow the same specifications as Adaptive icons. If you need to adjust your image, you can use a free editor, like Method Draw.

Resizing my icon to 80 x 80 within a 240 x 240 canvas

Open Shapeshifter and import your SVG file. If it’s not in a group, you must create one and move your layers under that group. Notice there’s a small clock to the right of each layer. That’s where we can set an animation for our SVG. Sadly, you can only add an alpha transition to the vector, hence you need to create a group. Groups can create rotations, scaling, translations, and so on. You can read more about it here.

First, check the dimensions of your vector and set the pivot by half of the height and width in your group. This will make the animation origin in the center.

Double-check the width and height of your vector
I’m setting the pivots X and Y with half of the height and width of the vector.

Now you can set the animation in the group. In this example, I’ve decided to use a rotation animation with an alpha transition.

The Android documentation suggests 1 second for the animations
The alpha transition settings from 0 (transparent) to 1 (opaque)
The rotation animation settings

Once you are happy with the result, export it as an “Animated Vector Drawable” and add it to your Android project.

Don’t forget to replace the old icon with your new animated icon. Also, you might need to add the animation duration:

“windowSplashScreenAnimationDuration” was introduced in API 31. It was meant to be used to set the animation duration. Sadly, it had a short life. It was deprecated in API 33 because the app can infer the animation duration based on the animated vector drawable you’ve set.

Now let’s see the result!

Not so bad, huh? Now you know how to include animations in your splash screens.

BONUS TRACK: Branding

Want to add a branding image to the splash screen? Sure! You only need to set the “android:windowSplashScreenBrandingImage” property:

And this is the outcome:

I hope this can help you. As always, you can check the source code here. Happy coding!

Free Consultation

Sign up for a FREE consultation with one of Trailhead's experts.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Adding a New Android Permission in a Xamarin App

As you know, Android is always adding features in its new versions and now the Post Notifications permission has been introduced from Android 13. In this blog, we are going to explore how to request it in our Xamarin.Android projects. Sampl

Read More

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.