androidx.core.splashscreen


This Splash Screen library provides compatibility support for the android.window.SplashScreen APIs down to API 21, with support of the splash screen icon from API 23.

It is composed of a compatibility theme Theme_SplashScreen that needs to be set as the starting theme of the activity and a programmatic API in androidx.core.splashscreen.SplashScreen.

To use it, the theme of the launching Activity must inherit from Theme.SplashScreen

AndroidManifest.xml:

    <manifest...>
        <application>
        <activity>
             android:name=".MainActivity"
             android:theme="@style/Theme.App.Starting"/>
     </manifest>
res/values/styles.xml:
<resources>
    <style name="Theme.App" parent="...">
    ...
    </style>

   <style name="Theme.App.Starting" parent="Theme.SplashScreen">
       <item name="windowSplashScreenBackground">@color/splashScreenBackground</item>
       <item name="windowSplashScreenAnimatedIcon">@drawable/splashscreen_icon</item>
       <item name="windowSplashScreenAnimationDuration">2000</item>
       <item name="postSplashScreenTheme">@style/Theme.App</item>
</resources>
MainActivity.java:
    class MainActivity : Activity {
        fun onCreate() {
            super.onCreate()
            val splashScreen = installSplashScreen()

            // Set the content view right after installing the splash screen
            setContentView(R.layout.main_activity)
        }
    }

Interfaces

SplashScreen.KeepOnScreenCondition

Condition evaluated to check if the splash screen should remain on screen

SplashScreen.OnExitAnimationListener

Listener to be passed in SplashScreen.setOnExitAnimationListener.

Classes

R
R.attr
R.dimen
R.style
SplashScreen

Provides control over the splash screen once the application is started.

SplashScreenViewProvider

Contains a copy of the splash screen used to create a custom animation from the splash screen to the application.