Android Splash Screen

In this tutorial, we will learn how to implement android splash screenAndroid splash screen we can see in every app. When app open it load the screen and in the background, some process is going on. Making Splash Screen is easy and simple.

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). XML file will be created automatically if you click blank new activity.
    3. To Make your splash screen activity as launcher activity, open your 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.
      <?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.
splash-screenYou can click on 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.

DOWNLOAD CODE