How to add a Splash Screen in Android 12

 Add the Dependancy :

//Splash Screen
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
Add a new Theme for Splash Screen:
<!-- Splash Screen Theme -->

<style name="Theme.App.Starting" parent="Theme.SplashScreen">
// Set the splash screen background, animated icon, and animation duration.
<item name="windowSplashScreenBackground">@color/white</item>

// Use windowSplashScreenAnimatedIcon to add either a drawable or an
// animated drawable. One of these is required.
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<item name="windowSplashScreenAnimationDuration">200</item> # Required for
# animated icons

// Set the theme of the Activity that directly follows your splash screen.
<item name="postSplashScreenTheme">@style/Theme.<YOURTHEME></item> # Required.
</style>
Add this code in MainActivity.kt
installSplashScreen()
Add this code in Manifest.xml
<application
    ...
android:theme="@style/Theme.App.Starting">

Comments