General app launch will display a white screen or a black screen page, and then jump to the Welcome page, so that the experience is not good. What the hell is going on here? How do you solve it? Today, let's analyze the cause of it and the solution.
1. Cause of production
When the system launches an app, the zygote process first creates a process to execute the app, but it takes time to create the process, and the user clicks on it and thinks it's not responding again, so the experience doesn't work. To address this obsession, the Android system will display a white screen or a black screen based on the body color set in your manifest, which is formally called Preview window , which is the previews.
2. Solutions
The essence of this problem is that although the code has not been executed, but the configuration file is read in advance, so we mainly for mainfest to solve this problem, more accurately, is the theme configuration file .
(1) Modify the theme of the activated activity
Here's how: STYLE.XLM
<style name= "Apptheme" parent= "@android: Style/theme.holo.noactionbar" > <item name= "Android: Windowbackground "> @drawable/splash_icon</item></style>
Also set the theme to the subject of the activity you started, Windowbackground is the preview window that will be displayed. One of the Splash_icon can be a whole picture, and many small partners on the web are doing the same. In fact, it can also be an XML file that can parse out the image resources, as if only layer-list this can be done, because it can be multiple drawable overlay to show. This way you can solve the problem of black and white screen. (2) Further optimization: Add animation generally our app will have a welcome page after it is launched, and then go to the homepage. According to the above practice, will show the picture first, then display the Welcome page, then to the homepage, from the picture to the Welcome page jump Transition is very abrupt, obsessive-compulsive disorder minutes can not endure ah ~ so we do further optimization: Add animation. In fact, preview window can only be a static diagram, not to show animation. We do this by jumping to the Welcome page to animate, that is, when preview widow jumps to the Welcome page, it displays a page that is exactly the same as the Preview window page, making it feel as if there is no switch and then slowly switching to the Welcome page. Here's a small question to note: The background image we set for the preview window will always be in memory if it is not processed, so restore the background image in the OnCreate to the Welcome page:
GetWindow (). Setbackgrounddrawableresource (Android. R.color.white);
To this start page black and white screen problem can be delivered ~
Android startup page black Screen Solutions