Android Splash Screen Example – Implementing Splash Screen

Hi everyone, welcome to another useful tutorial for beginners. So this post will show you an Android Splash Screen Example. An splash screen is a screen that shows up when we launch the app. Splash Screen is very common term and it is required for all the application. The idea behind this is, to show user a welcome screen while your application is loading.

In this android splash screen example we are going to learn how do we implement a splash screen in our application. So let’s begin.

Android Splash Screen Example

For building the Splash Screen the first thing needed is the design of the screen. But as this post is only an example we will not dig much into the designing part. Here I am going to use only a logo that I will display in the center of the screen.

Now let’s just create our android project.

  • Here I have created a new project using an EmptyActivity.
  • Once your project is loaded, first we will design our Splash Screen.

Designing Splash Screen

You can play with the design as much as you want. Here I am just using logo of StackOverflow to create a very quick design. It is having nothing just the logo image on the center.

For designing the Splash Screen we will create a drawable resource file.

  • Right click on the drawable folder and create a new drawable resource file. Here I have created splash_screen.xml.
android splash screen example
Creating Drawable Resource File
  • Here we are going to design our Splash Screen. So inside the file put the following code.

  • In the above code app_logo is the image file that I have already pasted inside my drawable folder, you need to put your logo that you want in the splash screen.
  • Now we will create a theme that will show this designed screen as the background of our activity.

Creating Splash Theme

  • Open the file res->values->styles.xml and modify it as below.

  • So we have a theme that will show up our Splash Screen. As you can see for the windowBackground of the theme we have set the splash_screen.xml.

Displaying Splash Screen

Let me first tell you the idea. The splash screen will show up only when the activity is not loaded, once the activity is loaded the splash screen will disappear. That is why we have set the splash screen as the windowBackground, so it will so the splash screen only when the activity is not loaded.

  • To achieve this objective we will change our MainActivity theme with the theme we created. So come inside AndroidManifest.xml and change the theme to App.Launcher, as shown in the below code.

  • Now when we launch the activity it will show the Splash Screen, and when the activity is loaded we will change the theme and then it will display our Activity.
  • So come inside MainActivity.java and change the theme inside the method onCreate().

  • Now run the application and you will see your designed splash screen before loading the activity. It may be too quick if your device is very fast.

So that is all for this Android Splash Screen Example friends. I hope you found it helpful. For any kind of question you can leave your comments.

And if you think the post is helpful please share this post with your friends. Thank You πŸ™‚

 

3 thoughts on “Android Splash Screen Example – Implementing Splash Screen”

  1. Instead of modifying android:theme in application tag of manifest file, it should be modified in mainactivity tag.
    If the activity’s tag is modified then one needs to specify setTheme method in every class.

    Reply

Leave a Comment