Android splash screen is basically a welcome screen or the first screen that visible to the user when opening an application. It can be used two ways, 1. If you want to showcase something like your company name and logo on application open. 2. If you want to do some background task with loading message and make the user wait till background task completes.

So in this blog, we will learn how to create and implement Splash screen in android with an example.

Step 1. Create an Android Project and create two activities one is SplashAcrivity and second is MainActivity. Set you SplashActivity as startup activity from AndroidManifest.xml file.

Step 2. Open activity_splash.xml and modify it according to your requirements. Below is my design code.

activity_splash.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#ffffff"

    android:gravity="center"

    android:orientation="vertical"

    tools:context=".SplashActivity">

  

    <ImageView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/icon" />

  

    <ImageView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/logo" />

  

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginTop="50dp"

        android:text="stdio.h welcoming you..."

        android:textSize="18dp" />

  

</LinearLayout>

Step 3. Now open SplashActivity.java file and modify it by adding the following code.

SplashActivity.java

package com.example.androidsplashscreen;

  

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.os.Handler;

import android.content.Intent;

  

public class SplashActivity extends AppCompatActivity {

  

    /* Splash screen waiting time: 3000 Milliseconds = 3 Seconds */

    private final int SplashScreenDisplayTime = 3000;

  

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_splash);

  

        /* Handler will make delay in opening next Activity */

        new Handler().postDelayed(new Runnable() {

            @Override

            public void run() {

                /* Intent to start next Activity */

                Intent intent = new Intent(SplashActivity.this, MainActivity.class);

                startActivity(intent);

                finish();

            }

        }, SplashScreenDisplayTime);

    }

}

In above code Handler().postDelayed() method is used to hold splash screen for a specific given time. Here I have a hold splash screen for 3 seconds as SplashScreenDisplayTime = 3000. 1 Second = 1000 Milliseconds. When 3 seconds will over, it will redirect to MainActivity.

Run your application and see the output. If you have any query comment to ask.

Output

I hope you like this blog. If you have any query, please comment below. Thank You… :)