How to handle transient black screen switching between Android activities

Source: Internet
Author: User

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"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.