How to make GIF Splash Screen In Android Studio | Animated | Attractive

We will make gif splash screen in android studio in today’s example.

You can make really great animated and attractive splash screen with GIF.

GIF provides seamless animation to the first impression of any android application.

Traditionally, we were making splash screen with static image.

Static Image may contain company name, logo, slogan etc. information.

There are some third party libraries available on the Github to make some cool animations with splash screen.

We were using those libraries before the concept of GIF was introduced.

Following are the necessary steps to create gif splash screen in android studio.

Step 1. Library

This project requires third party library to show the gif file in xml layout file.

We will use this github library : android-gif-drawable

Write below line in the build.gradle(Module: app) file

It will fetch all the necessary classes from our github library.

Step 2. Full Screen Activity

It looks great if your splash screen have full screen mode.

To make an android studio activity as a full screen, we have to change the style of our activity.

Add below source code in styles.xml file

Here we have created our own style which will hide the actionbar to enable the full screen.

Full source code for styles.xml file is as below

Now add the following line in the AndroidManifest.xml file under <activity> tag

Above line is setting our custom theme which we have just written in the styles.xml file.

So the final source code for AndroidManifest.xml file is as below

Step 3. WelcomActivity

First of all, we will create a new activity from now.

Keep the name of the new activity as Welcom Activity. It will be our first activity after splash screen has finished it’s loading.

Add the below code in activity_welcom.xml

Write down below line in WelcomActivity.java file

  • This activity is the main activity or the first activity of your android app.

Step 3. Saving GIF file

Obviously we need to have one gif file to load it on the android display screen.

Download the gif file by clicking the below link

[sociallocker]Download GIF File[/sociallocker]

After downloading the gif file, save it in the res->drawable directory.

Step 4. Main Activity Changes

Now it is time to play with GIF file.

  • Android have different layouts for different display factors. For example, imageview for image or picture, Textview for string, Button for clickable button, Edittext for input box etc.
  • But it has not any in built widget for GIF. Hence, we have to create it on our own.
  • This is where, that github library will help us.

Add following code to make a gif widget in activity_main.xml

Final code for activity_main.xml

  • Now it is time to set the time duration for the splash screen.

We will do this task from the MainActivity.java file

Following is the source code for the MainActivity.java file

Understanding the Above Code

Let us take a tour about main logic.

Give your attention to the following line

  • This line defines the time for which you want to show the splash screen to the user.
  • Here I have set it as the 5000 milli seconds which means that splash screen will be shown for the 5 seconds.
  • You can change time interval from this line as per your requirements.

Read the below coding lines

  • Above code will run the splash activity for specific time and then it will open the Welcom Activity.
  • I have used Handler class to accomplish our goal.
  • Inside the implementation of the Handler class, there is a method called run().
  • This method will be on hold for the time given by the variable SPLASH_DISPLAY_LENGTH
  • SPLASH_DISPLAY_LENGTH is an integer variable and will store the time in milli seconds.

After the time interval specified by the SPLASH_DISPLAY_LENGTH , Welcom Activity will be opened.

Splash Screen Tutorials

You can also visit below tutorial regarding android splash screen.

It was the details about making the animated splash screen with gif animation.

Do share our tutorials with other beginners and also mediators.

Thank you and nice day ahead!

View of GIF in Splash Screen

Download the source code for GIF Splash Screen

Click on below link to download the android studio source code

[sociallocker]Download Source Code For Splash GIF Animated Tutorial[/sociallocker]

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *