AndroidTutorial

What is Splash Screen in Android?

Splash screen in Android is the first thing or logo which a user came to see when an application starts. This splash screen in android is usually used to display the brand logo. Also, some basic information about the application in the android is shown using the Splash Screen of the application. So in this article, we’ll discuss the Splash screen in android and how to use and apply that.

Splash Screen in Android
Splash Screen in Android

In the android studio the Splash Screen in usually placed int he AndroidManifest.xml. There are many ways to create the splash screen, so let’s discuss every method one by one.

Splash Screen in Android Classic Approach

SW4GSplashActivity.java

package com.journaldev.splashscreen;

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

public class SplashActivity extends AppCompatActivity {

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

new Handler().postDelayed(new Runnable() {

@Override
public void run() {
// This method will be executed once the timer is over
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
finish();
}
}, 5000);
}
}

Code for Activity_splash.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<android.support.constraint.ConstraintLayout 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=”@android:color/black”
tools:context=”com.journaldev.splashscreen.SplashActivity”>

<ImageView
android:id=”@+id/imageView”
android:layout_width=”72dp”
android:layout_height=”72dp”
android:src=”@mipmap/ic_launcher”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintTop_toTopOf=”parent” />

<ProgressBar
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:indeterminate=”true”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
android:layout_marginTop=”8dp”
app:layout_constraintTop_toBottomOf=”@id/imageView” />

</android.support.constraint.ConstraintLayout>

Shareit for PC Windows 10

Keep the MainActivity.java empty as of now.

Setup the theme for the splash in android in the Theme.AppCompat.NoActionBar, you can file this in the AndroidManifest.xml

After adding all the above stuff in your application, you may get the black startup screen which is called the splash screen in android.

Splash Screen in Android
Splash Screen in Android

 

Advantages of splash screen in android application

  • It loads the initially required files of the application while displaying the splash screen.
  • The application requires some time to load the databases and some network information, which it can easily do while displaying the android application splash screen.

READ MORE ABOUT ANDROID SPLASH SCREEN HERE.

Tags
Show More

Related Articles

Leave a Reply

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

Back to top button
Close
Close