In this tutorial, I will discuss how to create splash screen using Kotlin in Android Studio.
What is a splash screen on an app?
The splash screen is a basically screen that is shown only a few seconds before launching an application or activity. This is the intro screen of an app. this screen helps users to get an overview of the app.
What is the purpose of a splash screen?
The purpose of a splash screen is to introduce the app to the user and do some initial work in the background to load the app function properly.
First of all, we need to create a new project in android studio.
How to create a new project in Android Studio?
- Click on to Start a new Android Studio project.
- Select a Project Template: Click Empty Activity.
- Enter the Project name: Android Splash Screen
- Enter the Package name : com.rockscoder.splashscreen
- Change Project save location if needed.
- Select Language as Kotlin from the dropdown.
- You may change the Minimum SDK version if you wish.
- Then click finish to create the project.
After clicking the finish button it may take few minutes to build the gridle dependency for the first time.
When all the background work is done your project will be ok for the next step.
How to remove action bar from splash screen
supportActionBar?.hide()
How to set splash screen timer in kotlin
You can declare your desire activity here to open after finishing the splash screen. After 3000 milliseconds / 3 seconds your next activity will display. Like MainActivity
Handler().postDelayed({
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
},3000)
See this video tutorial on how to create splash screen using kotlin.
You can also create an animated splash screen for your app using flutter, react native, or java.
Check out our other post on how to create Android Kotlin WebView Complete Tutorial