The realization method of Android splash screen _android

Source: Internet
Author: User

The example of this article describes the implementation of Android splash screen. Share to everyone for your reference. The specific analysis is as follows:

A splash screen is often used in an application to start a background thread to prepare resources for running the main program.
Android to implement the splash screen you can do this:

This is the code for the Splash.xml layout file:

Copy Code code as follows:
<linearlayout
Xmlns:android= "Http://schemas.android.com/apk/res/android"
android:layout_height= "Fill_parent" android:layout_width= "fill_parent" android:orientation= "vertical" >
<imageview android:layout_height= "fill_parent" android:layout_width= fill_parent "android:scaleType=" FitCenter "Android:src=" @drawable/splash "></ImageView>
</LinearLayout>

Put a imageview load splash picture
Splashactivity starts as the main view:

Copy Code code as follows:
/** called the activity is a. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.splash);
Handler x = new Handler ();
X.postdelayed (New Splashhandler (), 2000);

}
Class Splashhandler implements runnable{
public void Run () {
StartActivity (New Intent (Getapplication (), mainactivity.class));
SplashActivity.this.finish ();
}
}

I hope this article will help you with your Android program.

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.