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:
<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;
<style name= "Apptheme" parent= "Theme.AppCompat.Light.DarkActionBar"/> <style name= "Apptheme.brandedlaunch "Parent=" Apptheme "> <item name=" android:windowbackground "> @drawable/branded_logo</item></style >
<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)