Splash screens Android 12

Lokesh Deshmukh
Prog-Ramming Solutions
2 min readJul 6, 2021

According to Official Android Developer Site .

Android 12 adds the SplashScreen API, which enables a new app launch animation for all apps. This includes an into-app motion at launch, a splash screen showing your app icon, and a transition to your app itself.

Well this is a great new for all the developers. Now no more CODING for splash screen. Yay Yay!

GitHub Link : https://github.com/lokeshdeshmukh/SplashScreenAndroid12/

I am using Android Studio BumbleBee2021.1.1 Canary 2.

In this example, We are going to add one splash logo with white background for 1000ms (1 Sec).

Properties we need to add in themes.xml are :

<item name="android:windowSplashScreenBackground">#fff</item><item name="android:windowSplashScreenAnimationDuration">1000</item><item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_animate</item>

Were splash_animate is a drawable logo which you want to add for splash Screen.

This property is only supported on api level ≥ 31.

So your gradle file should look like this:

android {
compileSdkPreview "android-S"
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.myapplication"
minSdkPreview "S"
targetSdkPreview "S"
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}

S is Api level 31.

For windowSplashScreenAnimationDuration the maximum time is 1,000 ms.

Splash Exit Animation:
You can also add splash exit animation to see smooth transition to app’s main page. For that you need to add Splash Screen setOnExitAnimationListener.

splashScreen.setOnExitAnimationListener { splashScreenView ->
// Create your custom animation.
val slideUp = ObjectAnimator.ofFloat(
splashScreenView,
View.TRANSLATION_Y,
0f,
-splashScreenView.height.toFloat()
)
slideUp.interpolator = AnticipateInterpolator()
slideUp.duration = 500L

// Call SplashScreenView.remove at the end of your custom animation.
slideUp.doOnEnd { splashScreenView.remove() }

// Run your animation.
slideUp.start()
}

You need to add this in onStart() of launcher activity.

Happy Coding!

--

--

Lokesh Deshmukh
Prog-Ramming Solutions

Android developer | Photographer | Web Deveoper| Freelancer