How to implement Android Splash Screen

In this tutorial, we will learn how to implement android splash screenAndroid splash screen we can see in every app it is also known as lauch screen. When app open it load the screen and in the background, some process is going on.

Android Splash Screen Using Timer

    1. Open android studio, go to File ⇒ New Project and fill all the details.
    2. To make a Splash Screen you have to make a new activity. Name that activity as Splash_Screen.java (you can make according to your wish). The XML file will be created automatically if you click blank new activity.
    3. To Make your splash screen activity as launcher activity, open your (xml file) AndroidManifest.xml file.
      <?xml version="1.0" encoding="utf-8"?>
      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.androidhire.splashscreen">
      
          <application
              android:allowBackup="true"
              android:icon="@mipmap/ic_launcher"
              android:label="@string/app_name"
              android:roundIcon="@mipmap/ic_launcher_round"
              android:supportsRtl="true"
              android:theme="@style/AppTheme">
      
              <!-- Splash Screen-->
              <activity android:name=".Splash_Screen">
                  <intent-filter>
                      <action android:name="android.intent.action.MAIN" />
      
                      <category android:name="android.intent.category.LAUNCHER" />
                  </intent-filter>
      
              </activity>
      
              <!-- Main Activity-->
      
              <activity android:name=".MainActivity" />
      
          </application>
      
      </manifest>
    4. Go to res ⇒ layout then click on splash screen XML file. In this, you will show logo or text you want to show on a splash screen.

      If you want to save any images then you have to put image in res ⇒ drawable.

      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/bg_splash">
      
      
          <ImageView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_centerInParent="true"
              android:minHeight="0dp"
              android:minWidth="0dp"
              android:src="@drawable/logo_splash" />
      
      </RelativeLayout>
    5. Add code to SplashScreen.java activity. In this, you have to specify the time you want to wait on that screen and after that on which activity you want to go.
      package com.androidhire.splashscreen;
      
      import android.content.Intent;
      import android.os.Handler;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      
      public class Splash_Screen extends AppCompatActivity {
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_splash__screen);
      
              new Handler().postDelayed(new Runnable() {
                  @Override
                  public void run() {
                      Intent i = new Intent(Splash_Screen.this, MainActivity.class);
                      startActivity(i);
                      finish();
                  }
              }, 2000);
      
          }
      }
    6. I have added the background gradient, for that, you have to go res ⇒  drawable then make a file and make it bg_splash.xml. In place of a gradient, you can put some logo or normal text to show on the splash screen.
      <shape xmlns:android="http://schemas.android.com/apk/res/android"
          android:shape="rectangle">
          <gradient
              android:angle="90"
              android:endColor="#9b2a58"
              android:startColor="#290505">
          </gradient>
      </shape>

In the drawable folder only you have to add the logo. Run the application on the emulator or in your device and check the application.

You can click on the download button to download the code and go through the code to understand better how it works. If you are unable to understand or want some feature comment below.

 

Recent Articles

[Updated] Temporarily Free Games and Apps on Google Play Store

Every week there are free games and apps on the Google Play store. Here is the list of free games and apps on the Play Store you...

OnePlus 7T vs iPhone 11 | Specs Comparison

The OnePlus 7T and iPhone 11 are the two best phones if you looking for a price of less than $1000. Both the phone...

Elon Musk unveils Tesla’s Cybertruck

Are you into gaming or love watching sci-fi movies?  What about those back to the future movies which gave us a glimpse of the...

7 Best Hiking Apps you Must Try in 2020

Having the best hiking apps always gives you an advantage if you are going for adventurous trips. These apps can track your workout and activities...

[UPDATED] 9 Best Android Launcher Apps of 2019

Android launcher is best to customize the overall experience of Android for a user in terms of look and act. In apps store, there are...

Related Stories

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay on Top - Get the daily news in your inbox