DEV Community

Alonso Ato Neyra
Alonso Ato Neyra

Posted on

Android: Simple way to implement a SplashScreen in your app

First of all, what is a SplashScreen?

A splash screen is a screen which appears when you open an app on your mobile device. So, we can say it's the first impression for the user. It's usually used to show the logo of the app or an image related with the app.

In my personal opinion, this is the most simple way to implement a static splash screen.

So, let's code it.

First of all, create a new android project with a empty activity called SplashActivity.

Once that it's done we are ready to implement our SplashScreen:

1. Create a custom style in styles.xml under the res/values folder.

Fig.1 - Theme for SplashScreen.

2. On the AndroidManifest.xml, add the theme we created before to the SplashActivity.

Fig.2 - Add the theme to SplashActivity.

3. Add to the drawable folder any image you want, we gonna use it in the SplashScreen.

Fig.3 - Drawable folder.

4. Modify the activity_splash.xml.

Fig.4 - activity_splash.xml.

5. Add a new activity. I will called it MainActivity.

Fig.4 - activity_splash.xml.

6. Now, implement this code in the SplashActivity. I'll use a Handler to create a small delay and then go to the MainActivity.

Fig.5 - SplashActivity.kt.

And that's all! You have a SplashScreen in your app. Of course, you can use an animation and make it really awesome but I'll show it in another post.

Thanks for reading!

Here is the repo just in case:


Top comments (6)

rcosteira79 profile image
Ricardo Costeira • Edited

I prefer doing it without an Activity: create a style for the splash screen and set it as the main activity's style. Then, on the activity's onCreate, set the theme to the default theme and you're done. This immediately displays the splash screen (without that white screen that is sometimes displayed) and eliminates the need for an extra activity just to show the splash screen. However, it has the disadvantage of showing the splash screen again if you navigate to another activity and the main activity gets destroyed (for instance, due to resource constraints).
Regardless, since I've been using a single activity - multiple fragments architecture, the disadvantage doesn't really bother me :)

artesanoandroid profile image
Alonso Ato Neyra

Looks good because of your architecture but what if you wanna do an animation with the image? or something like that?

rcosteira79 profile image
Ricardo Costeira

You can add references to animations in a theme. You could, for example, create an animation-list with the animation you want and set it as the theme's windowBackground.

playboy2123 profile image

can you show me the way in steps plz?

rcosteira79 profile image
Ricardo Costeira

I have an example of this in a repo:

1 - Create the splash screen style like in

2 - Set it as the main activity's theme like in

3 - Reset the theme in the main activity like in

Thread Thread
pshdevio profile image

Thanks Ricardo, this works perfectly !