Android Project Create Welcome page

Source: Internet
Author: User

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

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.