Splash Screen – Create your own | Androidmonks

Splash Screen – Create your own in Android

Splash screen is the opening page that pops out with a bold and clear banner with the App name and logo. This screen creates a bold statement setting up the application for the user. It is important to know that, the splash screen is vital if there is a background service, that is going to load content. You do not want your user to wait for the content.

Splash screens have been around for a long time, but the current trend is to create an application and deliver content at lightning speeds, hence the need for Splash Screens are declining.

YOU ARE YOUR BOSS
I agree to have my personal information transfered to MailChimp ( more information )
Join over 5.000 visitors who are receiving our free content and learn how to program with Android. The growth of Android is estimated to reach a whooping 83% by 2020. Hop on the train and start making money!
We hate spam. Your email address will not be sold or shared with anyone else.

Creating a Splash screen is not a very difficult task, rather a design oriented task. You have to get your Design on point, and at the same time keep it simple.

Think of Splash screens as a Layout showing up on the screen for sometime (Usually its a 20-30 screen) before going into the main activity. There can also be scenarios where, a service loads content in the background (Which can send a intent on completion of the loading) and the next activity is launched after the content loads up.

Before you jump on to creating your Splash Screen, think about the situation you need the splash screen for, if it is going to be a very quick 5 second showing off of your brand, it can be a static splash screen every time the app loads (Can create a negative Customer experience also), instead if it is a resource heavy application, use the Splash Screen wisely, while you load the content in the background.

Splash Screen – How to create one

This is going to be straight forward simple implementation of the screen. Create a Layout which is going to be your Spash Screen design.

We will create a SplashActivity that will hold your Layout for some seconds and then fire the next MainActivity.

Check the below Layout Implementation. I have created a sample layout with Background and a Static logo to create my Screen.

Layout Implementation

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:background="#008080"
    android:gravity="center">
    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/monk"
        android:layout_gravity="center"/>

</LinearLayout>

I have put my monk.png in the res>drawable folder. Make sure your drawables are present based on different resolution in order to create uniform looking splash screen (Drawables changes based on the Image Resolution).

Creating Our SplashActivity

Jumping straight to our SplashActivity, we will be creating this one with a handler that will fire the intent after a delay of 2.5 seconds or 2500 milli seconds. This is what we have done below.

package com.monks.android.newapplication;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    Handler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        handler=new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent=new Intent(SplashActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        },2500);
    }
}

Creating the MainActivity

Once the SplashActivity is developed, we will create our MainActivity that will be shown right after the SplashActivity (Oftenthe starting point of the Application). I have created a bare minimum simple MainActivity like below.

package com.monks.android.newapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_acc);


    }
}

main_acc.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sample Activity"/>
</LinearLayout>

Final Product

Once done, it is time to stitch it all up and see the end product. Check out below for the Output.

"<yoastmark

Drop in any comments you have below.

“Learn and Be Curious”

Also Read  Bounded Service Android With Example | AndroidMonks

Leave a Comment

Your email address will not be published. Required fields are marked *