Thursday 26 December 2013

Splash screen in android application

Today In this tutorial i am going to explain you how we can add a splash screen to our android application. Splash screen is basically a screen which comes for few seconds when we opens a application. this makes our app more impressive because we can put a image of our origination. So lets start ......

First Step:- Create a layout in which you have to add a background image to the layout like this.

<?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"
    android:background="@drawable/splesh_screen"
    android:orientation="vertical" >

</LinearLayout>

Second Step:- Now its time to write some coding. In the java file you have to create a thread and make the thread sleep as per your convince.Put the code in oncreate method 

the code will be......

        
        Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(5000);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }finally {
                    Intent wp = new Intent(splash.this,MainActivity.class);
                    startActivity(wp);
                }
            }
        };
        timer.start();
   

Snapshots:-


https://adf.ly/bF8NK Click here to Download the project :-

No comments:

Post a Comment