The splash screen’s trick with animated content — ERRATUM

Written by jacquesgiraudel | Published 2017/09/30
Tech Story Tags: android | splash-screen | android-app-development | android-development

TLDRvia the TL;DR App

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


Published by HackerNoon on 2017/09/30