Create Splash Screen in Android Studio,Eclipse example tutorial

How to make/implement simple splash screen in android app activity using handler and thread.

Splash screen means a simple application screen that’s show on screen while app loads its content online in background through internet at the app first start-up time, But some times splash screen help us to show company or organization web mark logo so its user can easily understand about its name or see Logo. So in this tutorial we are simply display image as splash screen and after a while( 2-3 seconds ) we will hide the splash screen and redirect to application MainActivity.java home page. So here is the complete step by step tutorial for Create Splash Screen in Android Studio,Eclipse example tutorial.

android-project-download-code-button

Note : Download splash_demo_image from below and copy inside drawable-hdpi folder.

drawable hdpi folder

This is splash_demo_image image.

splash_demo_image

How to Create Splash Screen in Android Studio,Eclipse example tutorial.

Code for MainActivity.java file.

 package com.splashscreen_android_examples.com;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends Activity {

 ImageView imageview;
 int status = 0;
 Handler handler;
 Thread thread;
 TextView textview;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 imageview = (ImageView)findViewById(R.id.imageView1);
 textview = (TextView)findViewById(R.id.textView1);
 textview.setVisibility(View.GONE);
 
 handler = new Handler();
 
 thread = new Thread(new Runnable()
 {
 @Override
 public void run() 
 {
 while(status < 10)
 {
 try {
 Thread.sleep(300);
 } catch (InterruptedException e) {

 e.printStackTrace();
 }

 status++;
 }

 handler.post(new Runnable()
 {
 @Override
 public void run()
 {
 
 // Define here UI element change code.
 
 imageview.setVisibility(View.GONE);
 
 textview.setVisibility(View.VISIBLE);
 
 }
 });
 }

 });
 thread.start();

 
 }
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context="com.splashscreen_android_examples.com.MainActivity" >

 <ImageView
 android:id="@+id/imageView1"
 android:layout_width="wrap_content"
 android:layout_height="fill_parent"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:src="@drawable/splash_demo_image"
 />

 <TextView
 android:id="@+id/textView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:text="This is Application Home Page."
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:gravity="center" />

</RelativeLayout>

Screenshots:

Create Splash Screen in Android Studio,Eclipse example tutorial

 

SplashScreen-2

Click here to download Create Splash Screen in Android Studio,Eclipse example tutorial project with source code.

Leave a Reply

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