How to make splash screen in Android
Hello World, Today we are going to see how we can make a beautiful Splash Screen in your Android App.
Before start coding let's see, According to Wikipedia what is splash screen:
A splash screen is a graphical control element consisting of a window containing an image, a logo, and the current version of the software. A splash screen usually appears while a game or program is launching.
A splash page is an introduction page on a website.[1][2] A splash screen may cover the entire screen or web page, or may simply be a rectangle near the center of the screen or page. The splash screens of operating systems and some applications that expect to be run in full screen usually cover the entire screen.
So basically a Splash Screen is when you start an app the first screen with some graphics is a Splash Screen. See below as an example of the Whatsapp splash screen.
How to add a Splash screen in an App
In android, the Splash screen is an activity with a timer to open the next activity it is as simple as that.
So let's create a new activity in our app and we name it as SplashScreenActivity.
Now by default, we have launching activity is MainActivity we need to change launching activity with SplashScreenActivity. To do this go to your manifest.xml file and cut the main activity's intent filter and paste in splash screen activity.
See below.
Now if we run our app and launch it, The Splash Screen Activity will be called.
See also: Pass Data between Activities
Okay, now we will design our splash screen as per our requirement.
I am adding a textview and app logo in the splash screen see below.
Now if we run we can see our designed splash screen.
Now we need to add a timer that will trigger our next activity.
To add a delay or timer we will use Handler Class in android and use its postDelayed method and pass the Runnable interface and implement its run method.
In the run method, we will call our next activity and finish SplashScreenActivity.
See the below code.
After passing the runnable interface we need to pass time in milliseconds, here we are passing 2000 which means 2 seconds.
Now run your app and check your splash screen.
splash screen in android github, splash screen in android tutorials point, splash screen in android javatpoint, android studio splash screen animation, advanced splash screen in android, splash screen in android geeksforgeeks
Your Splash screen is ready to rock. Hope you learned something new.
Thank you or reading. Have a nice day.