How to create Splash Screen using Android Studio

Splash Screen one of the exciting feature in android, is referred to a welcome screen or user’s first experience of an application. A professionally designed Splash Screen has a possibility of making your Application look more professional.

So lets start and please follow my steps :

Step 1. Create a new activity name “SplashScreen”

Here you can create a new project after grading or build your project then you start to create a new activity name as “SplashScreen”

Step 2. Go to splashscreen_activity.xml file

This layout contains your app logo or other product logo that you want to show on splash screen.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="#ffff"
    android:orientation="vertical"
    tools:context=".SplashScreen">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:orientation="vertical">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="280dp"
            android:paddingBottom="40dp"
            android:src="@drawable/team_work" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Team Work "
            android:textColor="@android:color/black"
            android:textSize="40sp"
            android:textStyle="bold" />

        <ProgressBar
            android:id="@+id/splashProgress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp" />

    </LinearLayout>
</RelativeLayout>

Step 3. Go to SplashScreen.java file


public class SplashScreen extends AppCompatActivity {
    ProgressBar splashProgress;
    int SPLASH_TIME = 3000; //This is 3 seconds

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



        //This is additional feature, used to run a progress bar
        splashProgress = findViewById(R.id.splashProgress);
        playProgress();

        //Code to start timer and take action after the timer ends
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //Do any action here. Now we are moving to next page
                Intent mySuperIntent = new Intent(SplashScreen.this, LoginPanel.class);
                startActivity(mySuperIntent);

                //This 'finish()' is for exiting the app when back button pressed from Home page which is ActivityHome
                finish();

            }
        }, SPLASH_TIME);
    }

    //Method to run progress bar for 5 seconds
    private void playProgress() {
        ObjectAnimator.ofInt(splashProgress, "progress", 100)
                .setDuration(4000)
                .start();
    }
}

Step 4. Go to app/manifests





That’s it, friends, this is the correct and simple way to create a SplashScreen using in your app to look professional app. Just follow the above steps and copy paste code carefully at the correct location mentioned above.

if you found this article helpful please do comment below and share the article to support me. if you have any suggestion please feel free to comment below.

Leave a Comment

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