1、create a startup image splash.png and place it in the res-> drawable-hdpi folder.
2. Create a layout file splash. xml
<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Android: gravity = "bottom | Center" Android: Orientation = "vertical"
Android: Background = "@ drawable/Splash">
<Textview Android: text = "@ + ID/textview01" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: layout_margintop = "20dip"
Android: Typeface = "sans" Android: shadowdx = "0" Android: shadowdy = "2"
Android: shadowradius = "1" Android: shadowcolor = "# ffffff"
Android: textcolor = "#444444" Android: textsize = "20dip" Android: Id = "@ + ID/versionnumber"
Android: gravity = "bottom">
</Textview>
</Linearlayout>
The image created in the previous step is used as the background image of the startup interface, and the current image is displayed at the bottom of the interface.Program.
3. Create a splashactivity and add the following to oncreate:Code: // Http://www.my400800.cn
Setcontentview (R. layout. Splash );
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 (){
@ Override
Public void run (){
Intent intent = new intent (splashactivity. This, splashscreenactivity. Class );
Startactivity (intent );
Splashactivity. This. Finish ();
}
},2500 );
4. Modify the manifest file, change the activity on the startup interface to start by default, and set the title bar to be invisible.
<? XML version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. lyt. Android" Android: versioncode = "1" Android: versionname = "1.0">
<Application Android: icon = "@ drawable/icon" Android: Label = "@ string/app_name">
<Activity Android: Name = ". splashactivity" Android: Label = "@ string/app_name"
Android: theme = "@ Android: style/theme. notitlebar">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
<Activity Android: Name = ". splashscreenactivity" Android: Label = "@ string/app_name">
</Activity>
</Application>
<Uses-SDK Android: minsdkversion = "8"/>
</Manifest>
5. The display effect is as follows: