A short black screen solution for activity switching between activity in Android development _android

Source: Internet
Author: User

This example describes the solution to a short black screen between activity in Android development. Share to everyone for your reference, specific as follows:

By default, the Android application starts with a black screen period, because the first activity loads some data, such as initializing the list data, sending requests to the server, getting the data, and so on. Similarly, use startactivity (inte ...).

By default, the Android application starts with a black screen period, because the first activity loads some data, such as initializing the list data, sending requests to the server, getting the data, and so on. Similarly, a short black screen occurs during the process of using the startactivity (intent) method to move from an activity to a new activity. 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!

Step one: Customize Theme (subject)

Add the theme of the custom activity to the Your_project/res/values/styles.xml, as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
  <!--activity theme-->
  <style name = "Activitytheme" parent= "@android: Style/theme" >
    <item name= "Android:windowistranslucent" >true</ item>
  </style>
</resources>

where <item name= "android:windowistranslucent" 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, so this short black screen problem is solved.

Step two: Modify manifest to apply theme to target activity

Once the theme is defined, it is time to bind the theme for the corresponding activity. This code is implemented primarily in manifest, with the following attributes added to the activity:

<activity android:name= ". Activity. Placingorderstep1activity "
   android:theme=" @style/activitytheme "/>

OK, to solve this problem, do not believe, you will try!

More interested readers of Android-related content can view this site: "Introduction to Android Development and advanced tutorials" and "the activity of Android programming skills summary"

I hope this article will help you with the Android program.

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.