Skip to content
Career Lines
  • Home
  • Www.Careerlines.com
  • Call / WhatsApp : +91-9360056327 / +91-9600896874
  • Resources

How to create Splash Screen in Android Studio

December 18, 2019 by Admin

With the help of this blog we will cover implementation of splash screen in two scenarios. First will show splash screen using Handler & second we will not create a layout file for splash screen activity. Instead, specify activity’s theme background as splash screen layout.

In the first below example we will see the use of Splash Screen using Handler class.

For More Detailed Information: Click Here

How to Create a code Step by Step Guidance

STEP 1: Create a new project and the project name is Splashscreen1

STEP 2: Open res -> layout -> activity_main.xml (or) main.xml & add following code

In this step we simply added a code to display layout after Splash screen.

<?xml version=”1.0″ encoding=”utf-8″?>

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”

xmlns:tools=”http://schemas.android.com/tools”

android:id=”@+id/activity_main”

android:layout_width=”match_parent”

android:layout_height=”match_parent”

tools:context=”.MainActivity”>

<TextView

 android:layout_width=”wrap_content”

 android:layout_height=”wrap_content”

 android:text=”Hello World”

 android:textSize=”20sp”

 android:layout_centerInParent=”true”/>

</RelativeLayout>

STEP  3: Create a new xml file splashfile.xml for Splash screen and paste the following code in it.

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:gravity=”center”

    android:background=”@color/splashBackground”

    tools:context=”.MainActivity”>

    <ImageView

        android:id=”@+id/logo_id”

        android:layout_width=”250dp”

        android:layout_height=”250dp”

        android:layout_centerInParent=”true”

        android:src=”@drawable/logo” />

    <TextView

        android:layout_width=”wrap_content”

        android:layout_height=”wrap_content”

        android:layout_below=”@+id/logo_id”

        android:layout_centerHorizontal=”true”

        android:text=”Splash screen”

        android:textSize=”30dp”

        android:textColor=”@color/blue”/>

</RelativeLayout>

STEP 4: Now open app -> java -> package -> MainActivity.java and add the below code

package com.example.splashscreen1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

    }

}

STEP 5: For Splash Screen we will create a separate splash activity. Create a new class in your java package and name it as SplashActivity.java.

STEP 6: Add this code in SplashActivity.java activity. In this code handler is used to hold the screen for specific time and once the handler is out, our main Activity will be launched. We are going to hold the Splash screen for three second’s. We will define the seconds in millisecond’s after Post Delayed(){} method.

1 second =1000 milliseconds.

Post Delayed method will delay the time for 3 seconds. After the delay time is complete, then your main activity will be displayed.

SplashActivity.java 

package com.example.splashscreen1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

public class splash extends AppCompatActivity {

Handler handler;@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_splash);

 handler=new Handler();

 handler.postDelayed(new Runnable() {

 @Override

 public void run() {

Intent intent=new Intent(splash.this,MainActivity.class);

startActivity(intent);

finish();

}

},3000);

}

}

STEP 7: Open AndroidManifest.xml file and make your splashactivity.java class as Launcher activity and mention the Main Activity as another activity.

AndroidManifest.xml 

<?xml version=”1.0″ encoding=”utf-8″?>

<manifest xmlns:android=”http://schemas.android.com/apk/res/android”

package=”com.example.splashscreen1″>

<application

android:allowBackup=”true”

android:icon=”@drawable/logo”

android:label=”@string/app_name”

android:supportsRtl=”true”

android:theme=”@style/AppTheme”>

<activity android:name=”.splash”>

<intent-filter>

 <action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />

</intent-filter>

</activity>

<activity android:name=”.MainActivity”/>

</application>

</manifest>

Post navigation

Previous Post:

Google Adwords Measurements & Strategy

Next Post:

E-Mail Marketing

ENQUIRE NOW!!!

Recent Posts

  • Best Mern Stack Development Training Institute In Aruppukottai
  • Best Mern Stack Development Training Institute In Sivakasi
  • Best Mern Stack Development Training Institute In Srivilliputhur
  • Best Mern Stack Development Training Institute In Rajapalayam
  • Best Mern Stack Development Training Institute In Virudhunagar

Tags

Android Development Courses in Madurai Android Development Training Android Institute in Madurai Android Training Course Android Training Institutes in Madurai Basic HTML Basic HTML Coding digital marketing Free HTML Learning HTML for Beginners sem seo smm Web designing course in madurai Web Design Training Web development Web Development Training
June 2025
MTWTFSS
 1
2345678
9101112131415
16171819202122
23242526272829
30 
« Jan    
© 2025 Career Lines