Explain in detail how to deal with the short black screen in the jump between Android activities

Absrtact: how to solve the black screen problem when jumping between pages?

By default, there will be a black screen period when the Android application starts. The reason is that the first activity will load some data, such as initializing list data, sending a request to the server to obtain data, and so on. Similarly, when using the startactivity (intent) method to enter a new activity from an activity, a short black screen will appear in the process. The existence of this problem is determined by the Android application framework, but it does affect the user experience. Let's start to solve the black screen problem!

Step 1: Customize theme

In your_ Add the theme of the custom activity in project / RES / values / styles.xml, as shown below:

< item name = "Android: windowsistranslucent" > true < / item > means to set the target activity (the activity to start) to be transparent. It is easy to understand that there are two activities, a and B; Start B in a, because B is transparent and the background is still a, which solves the short black screen problem.

Step 2: modify the manifest and apply theme to the target activity

After the theme is defined, it is time to bind the theme for the corresponding activity. This code is mainly implemented in manifest, and the following attributes are added to the activity:

Do the above operations. I hope it will help you in your study, and I also hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>