1, make a start picture splash.png, placed in the res->drawable-hdpi folder.
2, Layout file
<span style= "FONT-SIZE:24PX;" ><?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/ Res/android " android:layout_width=" match_parent " android:layout_height=" Match_parent " android: background= "@drawable/splash" > <textview android:id= "@+id/versionnumber" android:layout_ Width= "Wrap_content" android:layout_height= "wrap_content" android:layout_alignparentbottom= "true" Android:layout_alignparentright= "true" android:layout_marginbottom= "26DP" android:layout_marginright= "52DP" android:text= "version 1.0" android:textcolor= ""/></relativelayout></span>
Here we take the image of the previous step as the background image of the launch screen, and then display the version number of the current program at the bottom of the interface.
3. New Splashactivity, add the following code in OnCreate:
<span style= "FONT-SIZE:24PX;" >packagemanager pm = Getpackagemanager (); try { packageinfo pi = pm.getpackageinfo ("Com.lyt.android", 0); TextView versionnumber = (TextView) Findviewbyid (r.id.versionnumber); Versionnumber.settext ("Version" + Pi.versionname);} catch (Namenotfoundexception e) { e.printstacktrace ();} New Handler (). postdelayed (New Runnable () {//important is this sentence @overridepublic void run () { Intent Intent = new Intent ( Splashactivity.this,splashscreenactivity.class); StartActivity (intent); SplashActivity.this.finish ();}}, 2500);</span>
4. Modify the manifest file, change the Start interface activity to default startup, and set the title bar to be invisible.
<span style= "FONT-SIZE:24PX;" ><manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "Com.example.sinaweibo" Android:versioncode= "1" android:versionname= "1.0" > <uses-sdk android:minsdkversion= "8" Android: targetsdkversion= "/> <application android:icon=" @drawable/ic_launcher "android:label=" @string/A Pp_name "Android:theme=" @android: Style/theme.notitlebar "> <activity android:name=". Mainactivity "android:label=" @string/title_activity_main "> <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.catego Ry. LAUNCHER "/> </intent-filter> </activity> <activity android:name=". M AinActivity1 "android:label=" @string/title_activity_main_activity1 "> <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "android.intent. Category. LAUNCHER "/> </intent-filter> </activity> </application></manifest></sp An>
This opens the app and waits 2.5 seconds to enter the second activity mainactivity.
Android Project Create Welcome page