Android Splash Screen is the first screen visible to the user when the application’s launched. Splash screen is one of the most vital screens in the application since it’s the user’s first experience with the application.

Splash screens are used to display some animations (typically of the application logo) and illustrations while some data for the next screens are fetched.

Android Splash Screen

Typically, the Activity that has the following intent filter set in the AndroidManifest.xml file is the Splash Activity.

Android Splash Screen Example Project Structure

android-splash-screen-project-structure

There are few ways to create the initial screen i.e. Splash Screen of the application. Let’s see each of them.

Splash Screen Classical Approach

We’re well aware of the classical approach of creating a splash screen in our application as shown below.SplashActivity.java

This is how we normally create the layout of our Splash Screen in our application:
activity_splash.xml

Let’s keep the MainActivity.java empty for now.

The output produced from the above implementation of SplashScreen is given below. We’ve set the theme of the SplashActivity to Theme.AppCompat.NoActionBar in the AndroidManifest.xml file.

android splash screen android studio classical approach

Did you see the blank page that came up before the Splash Screen was visible to you?

The above approach isn’t the correct approach. It’ll give rise to cold starts.

The purpose of a Splash Screen is to quickly display a beautiful screen while the application fetches the relevant content if any (from network calls/database).
With the above approach, there’s an additional overhead that the SplashActivity uses to create its layout.

It’ll give rise to slow starts to the application which is bad for the user experience (wherein a blank black/white screen appears).

Android Splash Screen Example with Correct Approach

The cold start appears since the application takes time to load the layout file of the Splash Activity. So instead of creating the layout, we’ll use the power of the application theme to create our initial layout.

Application theme is instantiated before the layout is created. We’ll set a drawable inside the android:windowBackground attribute that’ll comprise of the Activity’s background and an icon using layer-list as shown below.

splash_background.xml

We’ll set the following style as the theme of the activity.

styles.xml

The SplashActivity.java file should look like this:

Note: the theme of the activity is set before anything else. Hence the above approach would give our app a quicker start.

android splash screen example android studio

Using the theme and removing the layout from the SplashActivity is the correct way to create a splash screen.
This brings an end to android splash screen tutorial. You can download the final Android Splash Screen Project from the link below.

By admin

Leave a Reply