HomeMobileAndroidHow to implement Android Splash Screen

How to implement Android Splash Screen

This tutorial will teach you how to implement an android splash screenWe can see Android splash screens in every app, also known as the launch screen. When the app opens, it loads the screen, and some processes happen in the background.

Android Splash Screen Using Timer

  1. Open android studio, go to File ⇒ New Project and fill in all the details.
  2. To make a Splash Screen you have to make a new activity. Name that activity Splash_Screen.java (you can make it according to your wish). The XML file will be created automatically if you click blank new activity.
  3. To Make your splash screen activity a 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 the logo or text you want to show on a splash screen. If you want to save any images then you have to put an 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 on your device and check the application.

Go through the code to understand better how splash screens work. If you are unable to understand or want some features comment below.

Related Articles

Latest news

Unveiling the Darkest Elements in Hogwarts Legacy: Top 10 Elements

Hogwarts Legacy (Buy Now) is a jewel of a game for all the Harry Potter fanbase, inviting them to experience the magical universe of...

Dead Island 2 Cable Guy’s Van Keys location

As you embark on your journey in Dead Island 2, you'll stumble upon a mysterious vehicle known as the Cable Guy Van. This van...

iotty Smart Switch – Complete Review

The smart home industry is rapidly evolving with a plethora of innovative devices vying for consumers' attention. Among these, the iotty Smart Switch stands...

How To Fix Snapchat Support Code SS06

Every Snapchat user cherishes the joy of sharing moments, using filters, and connecting with friends. However, this joy can be interrupted by various glitches...

Can You Refund Fortnite Accounts?

Fortnite, the battle royale game developed by Epic Games, has taken the gaming world by storm since its inception. With its captivating gameplay, interactive...

Stay in the Loop

Get the weekly email from Android Hire that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.