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.

 

Aditya Singh
Aditya Singh
Hi, I’m Aditya Singh. The Co-Founder of this blog AndroidHire. I’m Part-Time blogger, and digital marketer. If you want to contribute then you can contact us at contact@androidhire.com

Latest news

One Plus 8T: All you need to know!

One Plus unveiled its 2020 flagship in a virtual event named One Plus 8T. In this post we would go through its...

Twitter may launch new features to simplify direct messages.

Twitter is said to be working on a couple of new features that could make it easier to manage direct messages...

Zoom Adds External Authentication Feature to make Virtual Classrooms more secure.

Zoom has introduced an external authentication feature to make virtual classrooms more secure. SSO will allow students to log in one...

Facebook, Twitter take action over Trump’s misleading COVID-19 posts.

Facebook and twitter took action on posts from US president Donald Trump on Tuesday for violating their rules against coronavirus misinformation...

Related news

One Plus 8T: All you need to know!

One Plus unveiled its 2020 flagship in a virtual event named One Plus 8T. In this post we would go through its...

Twitter may launch new features to simplify direct messages.

Twitter is said to be working on a couple of new features that could make it easier to manage direct messages...

Zoom Adds External Authentication Feature to make Virtual Classrooms more secure.

Zoom has introduced an external authentication feature to make virtual classrooms more secure. SSO will allow students to log in one...

Facebook, Twitter take action over Trump’s misleading COVID-19 posts.

Facebook and twitter took action on posts from US president Donald Trump on Tuesday for violating their rules against coronavirus misinformation...

LEAVE A REPLY

Please enter your comment!
Please enter your name here