Android app start black and white

When we open an APP, certainly we hope that it can respond quickly, and quick start. Before when we first start APP, APP of the first page and then displayed, this time there will be a few seconds of blank screen or a black screen. This gives the user experience is very bad.
The reason this happens is because when we start an application, the system checks whether there is already such a process, if not, Android system will create a new process assigned to the application, to be followed in order to create and Application class initialization, and then start SplashActivity class. Black and white display problem is generated during this time.
The system will load the page before drawing a layout, first initializes the window (Window), and during this operation, the system will specify its color according Theme Theme theme we set. Window top-level layout is DecorView, StartingWindow shows an empty DecorView, and then we set the Style determines the display of a black and white or black.

Solution:

Set up a separate Theme theme on the first page of the application to be launched (ie, application launch page) in.
   <activity
            android:name=".ui.SplashActivity"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
    </activity>

The above code android:theme="@style/SplashTheme"specifies the subject of your start page.

code show as below:
 <!--欢迎界面主题-->
    <style name="SplashTheme" parent="AppTheme">
        <item name="android:windowBackground">@drawable/splash_speed</item>
    </style>

APP black and white when this problem started to get up!

Guess you like

Origin blog.csdn.net/u014619545/article/details/93464878