Efficient Start Page (Splash)

Source: Internet
Author: User

Many applications need a page to display the company's brand or logo, or even if the page is not needed, if the layout is more complex, the launch of the application will have a short white screen (related to the system theme), often we will write a separate activity, and then display a picture or logo, Set a fixed time delay to start a real mainactivity, so it's a fuss, share a small skill:


    • First use Layer-list to define a hierarchy of drawable:

<layer-list xmlns:android= "Http://schemas.android.com/apk/res/android" > <item> <color android:col Or= "@color/background_material_light"/> </item> <item> <bitmap android:src= "@dra Wable/launch_logo_image "android:tilemode=" Disabled "android:gravity=" center "/> </item>& Lt;/layer-list>

Define the background and a bitmap display Logo,logo center display, the area beyond the bitmap size is not tiled or other processing;

    • It is then applied to the global background (when the app starts, the theme is rendered first, if the theme is not set by default using the system):

<style name= "Apptheme" parent= "Theme.AppCompat.Light.DarkActionBar"/> <style name= "Apptheme.brandedlaunch "Parent=" Apptheme "> <item name=" android:windowbackground "> @drawable/branded_logo</item></style >
    • Entry Activity Settings topic:

<activity android:name= ". Mainactivity "android:label=" @string/app_name "android:theme=" @style/apptheme.brandedlaunch ">

As this will change the overall theme, want to go back to the original system default theme can be changed dynamically in OnCreate:

@Overrideprotected void OnCreate (Bundle savedinstancestate) {setTheme (r.style.apptheme);    Super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main);}


Before the app starts, a short white screen is displayed:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/77/wKiom1XkFjjj3lcaAAXNDW0RgZc336.gif "title=" Branded_launch_no_brand.gif "alt=" Wkiom1xkfjjj3lcaaaxndw0rgzc336.gif "/>


After using this method:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/77/wKiom1XkFoTwjtu_AAYYswADWMo994.gif "title=" Branded_launch_with_brand.gif "alt=" Wkiom1xkfotwjtu_aayyswadwmo994.gif "/>


is not much more comfortable.


Reference from Antonioleiva, source GitHub repository


This article is from the "Beyond the Dream" blog, please be sure to keep this source http://lbrant.blog.51cto.com/2400264/1690191

Efficient Start Page (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.