Splash Screen in Android ?

This example demonstrates splash screen with animation effect. Few animation effects are also listed below which may resides in anim folder.

public class Splash extends Activity {
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
//2000 milli seconds are delaying time to redirect to NextActivity
 mHandler.sendEmptyMessageDelayed(0, 2000);

 }
 private Handler mHandler=new Handler()
 {
  public void handleMessage(android.os.Message msg)
  {
    startActivity(new Intent(Splash.this, NextActivity.class));
    overridePendingTransition( R.anim.slide_in_left, R.anim.slide_out_left );
    finish();
  };

 };
 }

res/anim:

<!--slide_in_left.xml:-->
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromXDelta="100%p" android:toXDelta="0%p"
 android:duration="@android:integer/config_longAnimTime"/>
<!--slide_out_left.xml :-->

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromXDelta="0" android:toXDelta="-100%p"
 android:duration="@android:integer/config_longAnimTime" />
<!--FadeIn and FadeOut effects:--><!-- fadeout -->

<?xml version="1.0" encoding="UTF-8"?>

 <alpha xmlns:android="http://schemas.android.com/apk/res/android"
 android:interpolator="@android:anim/accelerate_interpolator"
 android:fromAlpha="1.0" android:toAlpha="0.0"
 android:duration="300" />
<!-- fadein -->
 <?xml version="1.0" encoding="utf-8"?>
 <alpha xmlns:android="http://schemas.android.com/apk/res/android"
 android:interpolator="@android:anim/accelerate_interpolator"
 android:fromAlpha="0.0" android:toAlpha="1.0"
 android:duration="300" />
<!-- slide in right and slide out right -->

 <?xml version="1.0" encoding="utf-8"?>
 <translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromXDelta="-100%p" android:toXDelta="0%p"
 android:duration="@android:integer/config_longAnimTime" />
 <?xml version="1.0" encoding="utf-8"?>
 <translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromXDelta="0" android:toXDelta="100%p"
 android:duration="@android:integer/config_longAnimTime" />

Advertisements

One thought on “Splash Screen in Android ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s