Android Welcome Interface Splash

Source: Internet
Author: User

The Android program opens with a full screen welcome interface, where I write a welcome interface with splash Code as follows

Mainactivity.java

Package Cn.wuxiaocheng.splash;import Android.app.activity;import Android.os.bundle;import Android.view.Window;        public class Mainactivity extends Activity {@Override protected void onCreate (Bundle savedinstancestate) {        Requestwindowfeature (Window.feature_no_title);        Super.oncreate (savedinstancestate);    Setcontentview (R.layout.activity_main); }}

Splashactivity.java

Package cn.wuxiaocheng.splash;import android.app.activity;import android.content.intent;import  android.os.Bundle;import android.os.Handler;import android.view.Window;public class  splashactivity extends activity {    private final int  splash_display_lenght=3000;    //     delay 3 seconds,, can not write this paragraph, directly below Splash_display_ Lenght change to delay time on line         //load Welcome screen      @Override      protected void oncreate (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 to         new handler (). Postdelayed (new runnable () {                @Override              public void  run ()  {                  //through intent open the final real main interface main this activity                  intent mainintent = new intent ( Splashactivity.this,mainactivity.class);                //Start Main interface                   splashactivity.this.startactivity (mainintent);                 //shut himself up with this opening screen                       splashactivity.this.finish ();               }                                }, splash_display_lenght);      }}

Activity_welcome.xml

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:orientation=" vertical "&    Gt <imageview android:layout_width= "match_parent" android:layout_height= "Match_parent" android:backg round= "@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"? ><manifest xmlns:android= "http// Schemas.android.com/apk/res/android "    package=" Cn.wuxiaocheng.splash "     android:versioncode= "1"     android:versionname= "1.0"  >     <uses-sdk        android:minsdkversion= "   "      android:targetsdkversion= " />    <application"         android: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 interface-->         <activity  &Nbsp;         android:name= "Cn.wuxiaocheng.splash.SplashActivity"             android:label= "@string/app_name"   >            <intent-filter>                 <action android: Name= "Android.intent.action.MAIN"  />                 <category android:name= "Android.intent.category.LAUNCHER"  />             </intent-filter>         </activity>        < Activity android:name= "Cn.wuxiaocheng.splash.MainActivity" ></activity>     </application></manIfest> 


Android Welcome Interface Splash

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.