Posted by: Nav Singh
Today we will explore Splash screen API which is introduced in Android 12.
Splash screen
- To make app startup a more consistent and delightful experience android team added a new app launch animation for all apps from the point of launch.
- It shows the app icon, branding icon(optional), and a transition to the app itself.
- This new experience brings standard design elements to every app launch.
- It provides customizable components so apps can maintain their unique branding.
Splash screen components

- App icon: It should be a vector drawable, it can be
static
oranimated
. Max duration for animations is1,000 milliseconds
. By default, thelauncher icon
is used. - App icon background: It is optional. If you need more contrast between the icon and the window background you can use it.
- As with adaptive icons, ⅓ of the foreground is masked.
- Window background: It consists of a single opaque color. By default,
windowbackground
color is used if the attribute is not set.
Animations
Splash screen animation consists of 2 animations (enter and exit animations).
- Enter animation: It consists of the system view to the splash screen. It is controlled by the system and is
not customizable
. - Exit animation: It consists of the animation that hides the splash screen. You can customize it. If you want to do
custom animation
then you need toremove the splash screen manually
when theanimation is done
.
Customize the splash screen in your app
- When you try to add any property related to the Splash screen into your default
themes.xml
, You will get an error because the Splash screen is available only forAPI 12 or higher
.

- So you need to create a
themes.xml
undervalues-v31 directory

You can customize various properties of the Splash screen
Background color
The background color for the splash screen, if not specify then system will calculate from windowBackground
.
<item name="android:windowSplashScreenBackground">#004d28</item>
Animation duration :
Maximum duration should be below 1000ms
<item name="android:windowSplashScreenAnimationDuration">800</item>
Branding icon: It’s optional. It is a drawable image that is placed at the bottom of the starting window.
<item name="android:windowSplashScreenBrandingImage">@drawable/api12_logo</item>
Icon background color :
<item name="android:windowSplashScreenIconBackgroundColor">#004d28</item>
Animated icon :
<item name="android:windowSplashScreenAnimatedIcon">@drawable/your_animated_image</item>
Custom exit animation
You can write your own custom exit animation for the Splash screen.
on API 12 or higher you can get access to Splash screen by calling getSplashScreen()
from your Activity
.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | |
// custom exit on splashScreen | |
splashScreen.setOnExitAnimationListener { splashScreenView -> | |
// custom animation. | |
ObjectAnimator.ofFloat( | |
splashScreenView, | |
View.TRANSLATION_X, | |
0f, | |
splashScreenView.width.toFloat() | |
).apply { | |
duration = 1000 | |
// Call SplashScreenView.remove at the end of your custom animation. | |
doOnEnd { | |
splashScreenView.remove() | |
} | |
}.also { | |
// Run your animation. | |
it.start() | |
} | |
} | |
} |
Show splash screen on-screen for longer periods
Splash screen gets dismissed when app draws its first frame .
- With the help of
ViewTreeObserver.OnPreDrawListener you can suspend the draw of the first frame based on your requirements.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | |
Log.d("MainActivity", "onCreate: I AM RUNNING ON API 12 or higher") | |
content.viewTreeObserver.addOnPreDrawListener(object : | |
ViewTreeObserver.OnPreDrawListener { | |
override fun onPreDraw(): Boolean = | |
when { | |
mainViewModel.mockDataLoading() -> { | |
content.viewTreeObserver.removeOnPreDrawListener(this) | |
true | |
} | |
else -> false | |
} | |
}) | |
} |
Job Offers
Demo
- With default app icon

- With animated icon

Check full sample code
GitHub – navczydev/SplashScreenAPISample: Splash screen API sample Android12 new API
?? ???? HAPPY CODING ???? ??
References
Android 12 Developer Preview 3
android-developers.googleblog.com
https://developer.android.com/about/versions/12/features/splash-screen
https://developer.android.com/reference/android/window/SplashScreen
https://developer.android.com/guide/topics/graphics/drawable-animation
Stay in touch
Nav Singh – Writer – Medium | LinkedIn
navczydev – Overview
Log In or Sign Up to View
JavaScript is not available.