Prerequisites: How to Create a Splash Screen in Android using Kotlin?
Android Splash Screen is the first screen visible to the user when the application’s launched. Splash Screen is the user’s first experience with the application that’s why it is considered to be one of the most vital screens in the application. It is used to display some information about the company logo, company name, etc. We can also add some animations to the Splash screen as well. In this article, we will be making an animated Splash Screen Using Kotlin. A sample GIF is given below to get an idea about what we are going to do in this article.
Steps to Create an Animated Splash Screen
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.
Step 2: Create an animation file
To create an animation file in android studio please follow the given instructions carefully. Go to the app > res > right-click > New > Android Resource Directory.
Then name the directory name as anim. And then click on OK.
Go to the anim > right-click > New > Animation Resource File
And name the file name as side_slide and click on OK.
Now add this code to the animated XML file. Below is the code for the side_slide.xml file.
Step 3: Create another activity
Go to app > java > first package name > right-click > New > Activity > Empty Activity and create another activity and named it as SplashScreen. Edit the activity_splash_screen.xml file and add image, text in the splash screen as per the requirement. Here we are adding an image to the splash screen. Below is the code for the activity_splash_screen.xml file.
Go to the SplashScreen.kt file, and refer to the following code. Below is the code for the SplashScreen.kt file. Comments are added inside the code to understand the code in more detail.
Step 4: Working with the AndroidMenifest.xml file
Go to the AndroidMenifest.xml file and add the following code in the Splash Screen Activity. This is used to hide the status bar or action bar.
Also, add <intent-filter> inside the Splash Screen Activity to make this activity as the starting activity. So whenever the app will execute the user can see the splash screen at the beginning. Below is the complete code for the AndroidMenifest.xml file.
Step 5: Working with the activity_main.xml file
Go to the activity_main.xml file and add a text which will show “Welcome to GeeksforGeeks” when the user will enter into the MainActivity. Below is the code for the activity_main.xml file.
Step 6: Working with the MainActivity.kt file
Do nothing in the MainActivity.kt file as we already created a new activity for the Splash Screen. Below is the code for the MainActivity.kt file
Find this project on Github: https://github.com/Gauravverma245/AnimatedSplashScreen
- Flutter - Animated Splash Screen
- How to Create a Splash Screen in Android using Kotlin?
- Android | Creating a Splash Screen
- Android | How to Create/Start a New Project in Android Studio?
- Android | Creating multiple Screen app
- How to scale different Views to all screen sizes in Android Studio?
- Screen Orientations in Android with Examples
- Locking Screen Orientation in Android
- How to Keep the Device Screen On in Android?
- Mirror Android Screen to PC using scrcpy
- How to Increase/Decrease Screen Brightness in Steps Programmatically in Android?
- How to Increase/Decrease Screen Brightness using Volume Keys Programmatically in Android?
- How to Detect Touch Event on Screen Programmatically in Android?
- How to Find the Screen Resolution of a Device Programmatically in Android?
- How to Change the Screen Orientation Programmatically using a Button in Android?
- How to Align Navigation Drawer and its Elements towards the Left or Right of the Screen in Android?
- How to Maximize/Minimize Screen Brightness Programmatically in Android?
- Android | Android Application File Structure
- Android | AdMob Interstitial Ads for Android Studio
- Android | Running your first Android app
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.