Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Correct Way to Add a Splash Screen in Android

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Google previously advised against utilizing a Splash Screen for Android Applications. It was pointless. Then, when they released the Material Design Specifications, several of us noticed that the Splash Screen had been renamed Launch Screen. Ideal for displaying your brand. So, what is the distinction between a terrible LaunchScreen and a good LaunchScreen?

So you’re undoubtedly asking, “How difficult can it be to create the ideal splash screen?” And you’re probably correct – we’re talking about a screen that will only be displayed for a few seconds (if that). And a screen that seems to flash a logo at the user before disappearing. So it can’t be that complicated. Nope!

Step by Step Implementation

Step #1: Creating a Background XML

To make a proper Splash Screen, you must first build a background that will display your brand’s logo on the screen. You must create an XML file in the res/drawable folder for this.


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
    <item android:drawable="@color/colorAccent" />
        <bitmap android:src="@drawable/gfgLogo"
                android:gravity="center" />

Step #2: Creating a dedicated custom theme for your Launch Screen

The following step is to design a unique theme for your Splash Activity. 

GeekTip: The theme should be inherited from Theme.AppCompat.NoActionBar, because we don’t want that status bar visible when we are showing Launch.


    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorNative">@color/colorNative</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    <style name="LaunchTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/background</item>

Step #3: Finally some code cooking

Now comes the fun part, where we control the launch screen, in the right way! The best part here is that unlike the conventional methods to add a Splash Screen there is no need to specify a content view for the SplashActivity because the SplashTheme will be applied to it. So, all you have to do is start your Android application’s MainActivity and then end the SplashActivity by using the finish() function. Here is the activity:


import android.content.Intent;
import android.os.Bundle;
public class LaunchScreen extends AppCompatActivity {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        Intent intent = new Intent(this, LandingActivity.class);

Step #4: Finally, setting up the theme

Now we have cooked everything, the only thing left now is to apply the theme for our activity which we created earlier in Step #2, that is pretty easy, just pop the Android.Manifest file and edit it the following way.


<?xml version="1.0" encoding="utf-8"?>
        <activity android:name=".LaunchScreen" android:theme="@style/LaunchTheme">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
        <activity android:name=".LandingActivity" />

And just like that you have the Splash Screen in the right manner, this method is so good that even if your app gets a cold start, even then there is no white theme, because the Android OS fetches the theme from the Manifest first, which makes up the time for the Splash!

My Personal Notes arrow_drop_up
Last Updated : 23 Jul, 2021
Like Article
Save Article
Similar Reads
Related Tutorials