Sunday, July 14, 2013

Android Simple Splash Screen

It is the very simple android splash screen with xml layout with splash screen background and display it for particular interval of time


1 )Create xml layout main.xml with splash screen background

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

2) Create java class Splash.java which is having a thread to display main.xml layout screen for particular interval of time


public class Splash extends Activity {

    @Override
    public void onCreate(Bundle saved .InstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Thread splashTimer =new Thread()
        {
        public void run()
        {
        try{
        sleep(3000);
                 startActivity(new Intent(Splash.this,language.class));
        }
        catch(Exception e)
        {
        Log.e("splash",e.toString());
        }
        finally
        {
        finish();
        }
        }
        };splashTimer.start();
    }

It is very simple android splash screen if you have any doubts comment it 

No comments:

Post a Comment