paint-brush
The splash screen’s trick with animated content — ERRATUMby@jacquesgiraudel
12,894 reads
12,894 reads

The splash screen’s trick with animated content — ERRATUM

by September 30th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Inflating a screen layout takes some times. On a cold start, it can cause the device to first display a blank screen before the first activity’s layout. A common technique is to use the app’s window background theme to fill this blank screen (eg with a branding icon). In this article, I will go further by showing how to animate this icon.

People Mentioned

Mention Thumbnail

Company Mentioned

Mention Thumbnail
featured image - The splash screen’s trick with animated content — ERRATUM
 HackerNoon profile picture

Inflating a screen layout takes some times. On a cold start, it can cause the device to first display a blank screen before the first activity’s layout. A common technique is to use the app’s window background theme to fill this blank screen (eg with a branding icon). In this article, I will go further by showing how to animate this icon.

The problem

The window background technique

Your layouts are inflated in a system view called the decor view. It’s this view that you see when the app launches before you first activity’s layout. The technique here is to fill this “blank screen” by styling this view with a drawable.

Animate the background

You have to use a drawable animation but it won’t launch alone, the trick here is to programmatically access the decor view to start it.

ERRATUM : the animation will not be started as soon as we want (see : https://plus.google.com/u/0/102434905935244657491/posts/991fZAikgC6?cfem=1)

Step by step

Define a drawable animation to use as background

Use it as window background theme in a specific style

In the manifest, configure your splash screen activity to use it

In your splash screen activity, recover the animation from the Decor View and start it

Result

A sample app is available on my github, happy reviewing :)


jacquesgiraudel/AnimatedSplashScreen_AnimatedSplashScreen - Sample app for an animated splashscreen (without blank screen on cold starts)_github.com

References :

Splash Screen the right way

Frame Animation in Android

Android Developer at jacquesgiraudel.com