Transferred from: http://www.cppblog.com/fwxjj/archive/2013/01/14/197259.html
By default, when Android applications start, there is a black screen period, because the first activity loads some data, such as initializing list data, sending requests to the server for data, and so on. Similarly, use startactivity (inte ...
By default, when Android applications start, there is a black screen period, because the first activity loads some data, such as initializing list data, sending requests to the server for data, and so on. Similarly, when you use the StartActivity (intent) method to enter a new activity from an activity, a short black screen appears in the process. The existence of this problem is determined by the Android application framework, but it does affect the user experience. Here's how to solve this black screen problem!
First step: Customizing Theme (Theme)
Add the theme for the custom activity in Your_project/res/values/styles.xml as follows:
View PlainCopy
- <?xml version= "1.0" encoding= "Utf-8"?>
- <resources>
- <!--activity Topics--
- <style name= "Activitytheme" parent= "@android: Style/theme" >
- <item name= "Android:windowistranslucent" >true</item>
- </style>
- </resources>
where <item name= "android:windowistranslucent" >true</item> means that setting the target activity (the activity to start) is transparent. It's easy to understand, two activity,a and b; start B in A, because B is transparent and the background is still a, which solves this short black screen problem.
Step Two: Modify the manifest to apply the theme to the target activity
Once the theme is defined, it is time to bind the theme to the corresponding activity. This code is implemented primarily in manifest, with the following attributes added to the activity:
View PlainCopy
- <activity android:name= ". Activity. Placingorderstep1activity "
- Android:theme= "@style/activitytheme"/>
OK, to solve this problem, if you do not believe, try it!