Efficient start page (Splash) to start splash
When many applications start, a page is required to display the company's brand or Logo, or even if this page is not needed, if the layout is complex, when starting an application, there will be a short white screen (related to the system topic). We often write an Activity separately and then display an image or Logo, set a fixed time delay to start the real MainActivity. In this way, you can share a small skill:
1234567891011 |
< layer-list xmlns:android = "http://schemas.android.com/apk/res/android" > < item > < color android:color = "@color/background_material_light" /> </ item > < item > < bitmap android:src = "@drawable/launch_logo_image" android:tileMode = "disabled" android:gravity = "center" /> </ item > </ layer-list > |
Define the background color and a bitmap Logo. the Logo is displayed in the center. Areas beyond the bitmap size are not tiled or processed;
12345 |
< style name = "AppTheme" parent = "Theme.AppCompat.Light.DarkActionBar" /> < style name = "AppTheme.BrandedLaunch" parent = "AppTheme" > < item name = "android:windowBackground" >@drawable/branded_logo</ item > </ style > |
1234 |
< activity android:name = ".MainActivity" android:label = "@string/app_name" android:theme = "@style/AppTheme.BrandedLaunch" > |
As this will change the overall theme, you can change it dynamically in onCreate to return to the original default theme:
123456 |
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppTheme); super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); } |
A short white screen is displayed before the application is started:
After using this method:
Is it much more comfortable.