splash screen android kotlin

Splash Screen Android Kotlin | Working Example Android

In this tutorial, I will explain how you can build a Splash Screen for your Android Application. So let us learn how to develop a splash screen in android using Kotlin language.

Before we start let’s first understand what is a Splash Screen.

What is a Splash Screen

A Splash screen is a quick screen that appears for one or more seconds before the main screen of the application displays. It can have Images, Text, Logo, or any similar details according to the application. It is a very common feature in android applications and is found almost in all android applications. Some applications display a progress bar in their splash screens before moving to the Main Activity.

Splash Screen In Android Kotlin

1- Start a new Android Studio Project and name it “SplashScreen” or you can name it whatever you want. Select API level 19 and the default language should be Kotlin.

2- Go to build.gradle (Module: app) and add this dependency.

 

 

3- Now, right-click on your package name and select New —> Activity —> Empty Activity. Name this activity as ” SplashScreen ” or name it whatever you want.

4- Go to activity_splash_screen.xml and change the default Constraint Layout to Relative Layout.

5- I will simply add an Image to my Splash Screen. You can add Images, Text, Logo anything as per your need.

6- Add an Image View to your Relative Layout with match_parent width and height.

7- After giving an id, width and height the final image view will be like this.

 

 

8- Now go to SplashScreen.kt file and in onCreate method add the following

code.

 

9- Above the onCreate method, we add a value to define how much time we are going to display our Splash Activity.

 

 

10- Now, in our own create method use Handler().postDelayed() method and inside this method we will call an intent to start our splash activity.

 

 

11- Go to your activity_main.xml file and change the default Constraint Layout to Relative Layout. Add a TextView in your Relative Layout like this.

 

 

12- Go to your AndroidManifest.xml file. Find the intent-filter code and add it under your Splash Screen activity like this.

 

 

13- Here we are done with our code. Run the application to see the output. Enjoy 🙂

OUTPUT

 

Splash Screen Android Kotlin | Working Example Android
splash screen android kotlin
Splash Screen Android Kotlin | Working Example Android
splash screen android kotlin

 

 

More Android Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!