Android avoid APP start flash black (Theme and Style)

A few days ago, Boss reaction, the machine every time you start the program will flash a black screen, the customer does not accept the. No way, can only think about how to solve, finally found the following method. Black is the main causes of flash when we start Activity, need to run onCreate and onResume will display interface. That is to say to some data, will be displayed. According to this idea, is it right? I put the work to reduce can avoid screen? The fact is, even if you onCreate what all don't do, will flash a black screen, because of the need for a certain period of time to initialize the analytic interface. The following is the solution:

(PS: The new QQ group, who are interested can join together: Android group: 322599434)

I define two Theme, the first kind of Theme is setting a background image. When the program starts, the first display a background image, to avoid black. The second Theme is the style is set to transparent, proceedings not black but the entire transparent, wait until after the one-time initialization interface display. Here to talk about the advantages and disadvantages of the two ways:

Theme1 program, interface to display the background image, and then refresh the other interface control. Give a person does not refresh synchronization feeling.

Can increase the above custom styles in Activity. In addition to increase in Application is also possible, but the overall effect.

Custom Theme in /res/values/styles.xml. If no such file, add a can.

If there are multiple Activity switching, intermediate may also exist a short black screen problem. When reason is Activity to start the initialization required loading data, if you want to avoid this situation, you can switch Activity increases above the style.

The above two kind of styles can be avoid screen. You can test your program to choose an effect.

This is to avoid a black screen, but if you initialize boot slowly, still give people the feeling of a slow start procedure. The need to optimize the initialization process.

android:theme="@android:style/Theme.NoTitleBar" //Don't show the application title bar of the android:theme= "@android:style/Theme.NoTitleBar.Fullscreen" // not to show the application of the title bar, And full screen android:theme="Theme.Light " //The background is white android:theme="Theme.Light.NoTitleBar" //The white background and no title bar android:theme="Theme.Light.NoTitleBar.Fullscreen" //White background, No title bar, Full android:theme= "Theme.Black" / "Theme.Black.NoTitleBar" android:theme= black background / black background and no title bar of the android:theme= "Theme.Black.NoTitleBar.Fullscreen" // black background, No title bar, Full android:theme= "Theme.Wallpaper" // with the desktop for the application background of android:theme= "Theme.Wallpaper.NoTitleBar" // with desktop application background, And no title bar of the android:theme= "Theme.Wallpaper.NoTitleBar.Fullscreen" // with desktop application background, No title bar, Full screen android:theme="Theme.Translucent" //Transparent background android:theme="Theme.Translucent.NoTitleBar" //Transparent background no titles android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //Transparent background no titles, Full android:theme= "Theme.Panel" // android:theme= display panel style "Theme.Light.Panel" // flat panel display style

4,Theme and Style

Android except Theme and Style, for example, the following is a Style Launcher workspace configuration

Style can be understood as a set of attribute set, convenient for different View settings to use, when we use Style in View, using the Theme method is applied to the same. What are the differences between Style and Theme? Below is a list of the differences:

The style used in the single View, such as: Button, TextView etc.

Theme by AndroidManifest.xml <application> and <activity> used in the entire application or a Activity theme, global impact on the entire application or a Activity.

If an application used theme, while application under view also used the style, so when a conflict occurs when the theme and style attributes, style has priority over the subject.

It is solved by Theme flash black start program, and on the Theme and Style, through the Theme configuration, but can also be a welcome page. But we all want to program the faster the better, it still needs a lot of optimize their programs.