Sitemap

Splash Screen API Android Implementation

2 min readJan 4, 2023

--

Press enter or click to view image in full size
Splash Screen API (Android 12)

Splash Screen is the first screen that comes whenever an app is launched. Starting in Android 12, the launch animation for all apps when running on a device with Android 12 or higher. This includes an into-app motion at launch, a splash screen showing your app icon, and a transition to your app.

This experience brings standard design elements to every app launch, but it’s also customizable so your app can maintain its unique branding.

So, let’s go through each step to let you configure the Splash Screen API.

STEP 1: Inside build.gradle(app), the compile SDK version should be 31, and add splash screen API compat library dependency.

android {
...
compileSdk 31
...
}

dependencies {
implementation "androidx.core:core-splashscreen:1.0.0
}

STEP 2: Create a Custom theme with the parent Theme.SplashScreen.

<style name="Theme.AppSplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/icon</item>
<item name="windowSplashScreenAnimationDuration">3000</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
<item name="android:statusBarColor">@color/white</item>
<item name="android:navigationBarColor">@color/white</item>
</style>

STEP 3: Inside AndroidManifest.xml, change the application theme to the Custom theme just created.

<application
...
android:theme="@style/Theme.AppSplash"
...
</application>

STEP 4: Inside your MainActivity, call installSplashScreen() before setContentView()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContentView(R.layout.activity_main)
}

NOTE: You don’t need to create a new Activity for SplashScreen instead just call the above function inside the MainActivity.

Get Shubham Agrawal’s stories in your inbox

Join Medium for free to get updates from this writer.

STEP 5: Build and run the app.

That’s it. Happy Coding 😁

--

--

Shubham Agrawal
Shubham Agrawal

Written by Shubham Agrawal

Technology Enthusiast | Entrepreneur