![]() |
VOOZH | about |
A splash screen is mostly the first screen of the app when it is opened. It is a constant screen that appears for a specific amount of time and generally shows for the first time when the app is launched. Splash screen is used to display some basic introductory information such as the company logo, content, etc just before the app loads completely.
In this tutorial, we'll implement a splash screen using the SplashScreen API, which is the modern and official way recommended by Google. This method works on Android 12+ and supports earlier versions using the support library.
Note: This Android article covered in Kotlin languages.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Note: Select Kotlin as the programming language.
In your build.gradle.kts (Module :app) file, add the following dependency
dependencies {
...
implementation("androidx.core:core-splashscreen:1.0.0")
}
Navigate to app > res > values > themes.xml and the add the following style. Create a new drawable resource file to scale the logo. Set the name as logo_inset.xml.
Navigate to app > manifests > AndroidManifest.xml and the set the default theme as the splash theme as shown below.
<application
...
android:theme="@style/Theme.App.Starting"
...>
...
</application>
Navigate to app > java+kotlin > {package-name} > MainActivity.kt and make the following changes. Also navigate to activity_main.xml in res > layout folder and make the following changes.