Theme of Android Activity

Source: Internet
Author: User

Follow the theme of the android activity (or translate it into a topic), which is caused by two online Android interview questions.
1. Activity Lifecycle
2. How to set an activity as a window style

First, let's talk about the lifecycle of the activity. when two activities are switched, if the second activity overwrites the first activity, the first activity will call the onstop method, the onstop method is no longer called after the onpause method is called. in this regard, I have previously devoted myself to exploration. http://www.cnblogs.com/leipei2352/archive/2011/08/09/2132279.html
Therefore, when learning the activity life cycle, in order to make the second activity not completely cover the first activity, I set the theme of the second activity:
<Activity Android: Name = ". activity02" Android: theme = "@ Android: style/theme. Dialog"> </activity>
Let's talk about other theme-related knowledge points. set theme in this window. I actually see theme in the teaching material, but it does not mention other theme. after I open the reference of theme in eclipse, a new file is opened: C: \ Program Files \ Android-SDK \ platforms \ Android-8 \ data \ res \ values \ theme. XML. this file defines theme that I don't know yet. but fortunately, each theme item is described above.
I wanted to list it here and found that it was a bit unrealistic. So many words are listed here, so it is inevitable that I will be suspected of using the number of words. I am more interested in theme. You can read this file by yourself. I will only list an interesting theme definition here.

   1: <!-- Default theme for translucent activities, that is windows that allow you

   2:      to see through them to the windows behind.  This sets up the translucent

   3:      flag and appropriate animations for your windows.  -->

   4: <style name="Theme.Translucent">

   5:     <item name="android:windowBackground">@android:color/transparent</item>

   6:     <item name="android:colorBackgroundCacheHint">@null</item>

   7:     <item name="android:windowIsTranslucent">true</item>

   8:     <!-- Note that we use the base animation style here (that is no

   9:          animations) because we really have no idea how this kind of

  10:          activity will be used. -->

  11:     <item name="android:windowAnimationStyle">@android:style/Animation</item>

  12: </style>

From the definition of theme, a theme is translucent after being set. Therefore, a theme activity cannot completely hide the previous activity. in this case, the previous activity started the second activity and will not call the onstop method. I tried it. Hey, that's it.

Pay more attention to theme of Android activity later.

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.