The Android program opens with a full screen welcome interface, where I write a welcome interface with splash Code as follows
Mainactivity.java
PackageCn.wuxiaocheng.splash;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.Window; Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {requestwindowfeature (window.feature_no_title); Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); }}
Splashactivity.java
PackageCn.wuxiaocheng.splash;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.view.Window; Public classSplashactivityextendsActivity {Private Final intsplash_display_lenght=3000;//delay 3 seconds,, can not write this paragraph, directly below the splash_display_lenght changed to delay time on the line//Loading the Welcome screen@Overrideprotected voidonCreate (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 NewHandler (). postdelayed (NewRunnable () {@Override Public voidrun () {//Open the final real main interface via intent main this activityIntent mainintent =NewIntent (splashactivity. This, Mainactivity.class); //start the main interfaceSplashactivity. This. StartActivity (mainintent); //turn off this opening screen for yourself .Splashactivity. This. Finish (); }}, Splash_display_lenght); }}
Activity_welcome.xml
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"> <ImageViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:background= "@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"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Cn.wuxiaocheng.splash"Android:versioncode= "1"Android:versionname= "1.0" > <USES-SDKandroid:minsdkversion= "+"android:targetsdkversion= "+" /> <ApplicationAndroid: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 screen - <ActivityAndroid:name= "Cn.wuxiaocheng.splash.SplashActivity"Android:label= "@string/app_name" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> <ActivityAndroid:name= "Cn.wuxiaocheng.splash.MainActivity"></Activity> </Application></Manifest>
Android Welcome Interface Splash