Here I will explain about to create splash screen in android
application.
Usually this type of screen used to show at first time when
opening the application.
Before start to do, you must collect the list of things..
1. Add image logo to display in splash screen
2. Need to create a new xml layout
3. Need to create a new activity java file
Code for Splash.xml
<?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="#ffffff">
<ImageView android:id="@+id/splashscreen"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/logo"
android:layout_gravity="center" />
</LinearLayout>
|
Code for mainactivity.java code
import
android.app.Activity;
import
android.content.Intent;
import android.os.Bundle;
import
android.os.Handler;
public class mainactivity extends Activity {
/** Called when the activity is
first created. */
private final int SPLASH_DISPLAY = 3000;
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new
Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an
Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(mainactivity.this,login.class);
mainactivity.this.startActivity(mainIntent);
mainactivity.this.finish();
}
}, SPLASH_DISPLAY);
}
}
|
That’s it now you can
start your application see the splash screen display first then it move to
login screen..
Post your valuable comments here.. Keep reading
0 comments:
Post a Comment