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

 PackageCn.wuxiaocheng.splash;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.Window; Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {requestwindowfeature (window.feature_no_title); Super. OnCreate (savedinstancestate);    Setcontentview (R.layout.activity_main); }}

Splashactivity.java

 PackageCn.wuxiaocheng.splash;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.view.Window; Public classSplashactivityextendsActivity {Private Final intsplash_display_lenght=3000;//delay 3 seconds,, can not write this paragraph, directly below the splash_display_lenght changed to delay time on the line//Loading the Welcome screen@Overrideprotected voidonCreate (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        NewHandler (). postdelayed (NewRunnable () {@Override Public voidrun () {//Open the final real main interface via intent main this activityIntent mainintent =NewIntent (splashactivity. This, Mainactivity.class); //start the main interfaceSplashactivity. This. StartActivity (mainintent); //turn off this opening screen for yourself .Splashactivity. This. Finish ();     }}, Splash_display_lenght); }}

Activity_welcome.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical">    <ImageViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:background= "@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"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Cn.wuxiaocheng.splash"Android:versioncode= "1"Android:versionname= "1.0" >    <USES-SDKandroid:minsdkversion= "+"android:targetsdkversion= "+" />    <ApplicationAndroid: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 screen -        <ActivityAndroid:name= "Cn.wuxiaocheng.splash.SplashActivity"Android:label= "@string/app_name" >            <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>        <ActivityAndroid:name= "Cn.wuxiaocheng.splash.MainActivity"></Activity>    </Application></Manifest>

Android Welcome Interface Splash

Related Article

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.