The Android program opens with a full screen welcome interface, where I write a welcome interface with splash Code as follows
Mainactivity.java
Package Cn.wuxiaocheng.splash;import Android.app.activity;import Android.os.bundle;import Android.view.Window; public class Mainactivity extends Activity {@Override protected void onCreate (Bundle savedinstancestate) { Requestwindowfeature (Window.feature_no_title); Super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); }}
Splashactivity.java
Package cn.wuxiaocheng.splash;import android.app.activity;import android.content.intent;import android.os.Bundle;import android.os.Handler;import android.view.Window;public class splashactivity extends activity { private final int splash_display_lenght=3000; // delay 3 seconds,, can not write this paragraph, directly below Splash_display_ Lenght change to delay time on line //load Welcome screen @Override protected void oncreate (bundle savedinstancestate) { requestwindowfeature (Window.feature_no_title); //Set Untitled super.oncreate (SavedInstanceState); setcontentview (r.layout.activity_welcome); // to reduce the code using anonymous Handler to create a deferred call to new handler (). Postdelayed (new runnable () { @Override public void run () { //through intent open the final real main interface main this activity intent mainintent = new intent ( Splashactivity.this,mainactivity.class); //Start Main interface splashactivity.this.startactivity (mainintent); //shut himself up with this opening screen splashactivity.this.finish (); } }, splash_display_lenght); }}
Activity_welcome.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 "& Gt <imageview android:layout_width= "match_parent" android:layout_height= "Match_parent" android:backg round= "@drawable/splash_welcome"/> </LinearLayout>
and set up a welcome interface for the first boot screen in Androidmanifest.xml.
Androidmanifest.xml
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http// Schemas.android.com/apk/res/android " package=" Cn.wuxiaocheng.splash " android:versioncode= "1" android:versionname= "1.0" > <uses-sdk android:minsdkversion= " " android:targetsdkversion= " /> <application" android:allowbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme" > <!-- The following activity setting opener is the first page for the Welcome interface--> <activity &Nbsp; android:name= "Cn.wuxiaocheng.splash.SplashActivity" android:label= "@string/app_name" > <intent-filter> <action android: Name= "Android.intent.action.MAIN" /> <category android:name= "Android.intent.category.LAUNCHER" /> </intent-filter> </activity> < Activity android:name= "Cn.wuxiaocheng.splash.MainActivity" ></activity> </application></manIfest>
Android Welcome Interface Splash