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.

<?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">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
        </activity>        <!-- Main Activity-->
        <activity android:name=".MainActivity" />

3. 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" />

4. 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.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

public class Splash_Screen extends AppCompatActivity {

  protected void onCreate(Bundle savedInstanceState) {
    new Handler()
        new Runnable() {
          public void run() {
            Intent i = new Intent(Splash_Screen.this, MainActivity.class);

5. 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>

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.

Aditya Singh
Aditya Singhhttps://optimizegoal.com
I'm a tech writer with over seven years of experience. I love to help people understand tech through my articles. I write about technology, mobiles, PCs, how-tos & guides, news and gadget reviews. I always stay updated with the latest in tech to give you the best info.

Related Articles

Popular Post