By default, the Android app starts a black screen period because the first activity loads some data, for example, initialize the list data and send a request to the server to obtain the data. Similarly, when you use the startactivity (intent) method to enter a new activity from an activity, a black screen will appear for a short time. The existence of this problem is determined by the Android Application Framework, but it does affect the user experience. Next we will solve this black screen problem!
Step 1: Customize theme)
Add the theme of the custom activity to your_project/RES/values/styles. XML, as shown below:
<Style name = "starttheme" parent = "@ Android: style/theme"> <item name = "Android: Movie wistranslucent"> true </item> <item name = "Android: windownotitle "> true </item> <! -- No title --> </style>
<Item name = "Android: javaswistranslucent"> true </item> indicates that the target activity (the activity to be started) is transparent. It is easy to understand that two activities, 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 2: Modify manifest and apply theme to the target activity.
After theme is defined, it is time to bind theme to the corresponding activity. This code is mainly implemented in manifest and the following attributes are added to the activity:
android:theme="@style/startTheme"