A splash screen is mostly the first screen of the app when it is opened. It is a constant screen which appears for a specific amount of time, generally shows for the first time when the app is launched. The Splash screen is used to display some basic introductory information such as the company logo, content, etc just before the app loads completely.
Creating Splash screen using handler in Android
Here we created two activities MainActivity showing the Splash Screen and SecondActivity in order to switch from MainActivity to SecondActivity. The main program is written in MainActivity, you can change activities as per your need.
- To remove the ActionBar, you need to make following changes in your styles.xml file.
style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" ...
- Use colors which is suitable for your application.
- No need to make any changes in your manifest file.
Using the ‘postDelayed()’ function:
public final boolean postDelayed(Runnable Object token, long delayMillisec)
This function delays the process for a specified time. This is used with a handler which allows you to send and process Message and Runnable objects associated with a Thread’s MessageQueue. Each handler instance is a single thread.
Below is the code for creating the splash screen:
activity_main.xml: You can use any image for the splash screen and first paste it into the drawable folder. XML file is easy to generate by drag and drop approach, just use imageview and select the appropriate image.
- Android | Creating multiple Screen app
- Android | Creating a SeekBar
- Android | Creating a RatingBar
- Android | Creating a Calendar View app
- Creating a Calculator for Android devices
- How to scale different Views to all screen sizes in Android Studio?
- Android | How to Create/Start a New Project in Android Studio?
- Android | Android Application File Structure
- Android | How to add Radio Buttons in an Android Application?
- Android | How to Request permissions in Android Application?
- Android | AdMob Banner Ads for Android Studio
- Android | AdMob Interstitial Ads for Android Studio
- Android | Running your first Android app
- Creating a file using FileOutputStream
- Creating Frames using Swings in Java
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.