Create a startup interface in Android to edit

Source: Internet
Author: User

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:

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.