Description of activity properties in Android (reproduced)

Source: Internet
Author: User

Transferred from: http://liuwuhen.iteye.com/blog/1759796

Activity is a very mundane component of Android that we need to master in addition to the life cycle in activity.

He set.

Settings for themes in 1.activity

in Android we can set the theme in the activity through androidmanifest.xml, in fact, Android offers a lot of its own theme styles, as follows:

Android:theme= "@android: Style/theme.dialog" displays an activity as a dialog box mode
Android:theme= "@android: Style/theme.notitlebar" does not display the application title bar
Android:theme= "@android: Style/theme.notitlebar.fullscreen" does not display the application title bar and full screen
Android:theme= "Theme.light" background is white
Android:theme= "Theme.Light.NoTitleBar" white background with no title bar
Android:theme= "Theme.Light.NoTitleBar.Fullscreen" white background, no title bar, fullscreen
Android:theme= "Theme.black" background black
Android:theme= "Theme.Black.NoTitleBar" black background with no title bar
Android:theme= "Theme.Black.NoTitleBar.Fullscreen" black background, no title bar, fullscreen
Android:theme= "Theme.wallpaper" with system desktop for application background
Android:theme= "Theme.Wallpaper.NoTitleBar" uses the system desktop as the application background with no title bar
Android:theme= "Theme.Wallpaper.NoTitleBar.Fullscreen" with system desktop for application background, no title bar, fullscreen
Android:theme= "Translucent"
Android:theme= "Theme.Translucent.NoTitleBar" Transparent, no title bar
Android:theme= "Theme.Translucent.NoTitleBar.Fullscreen" Transparent, no title bar, and full screen display
Android:theme= "Theme.panel"
Android:theme= "Theme.Light.Panel"

We can set different themes through the requirements.

2.android Activity Screen Settings

Since the phone can support the screen switch, when the android switch can be back to the layout of the page in the impact, when the Androidmanifest.xml file is defined in the android:screenorientation= "portrait", This means that when we switch the vertical screen, the contents of the screen are always displayed in portrait mode, and the content is not displayed according to the direction of the screen. and set to android:screenorientation= "Landscape" is the horizontal screen display.

Description of several values of Launchmode attribute in activity in 3.android

There are four states in the Launchmode.

Standard: Each time an instance is created, the activity is added to the current task by default.


Singletop: Start not the current activity, then create an instance, and join the current task, otherwise discard, intent do not do any reaction

Singletask: There is only one task that does not re-create an activity that already exists.

SingleInstance: There is only one activity in a task. When you start acivity, a task is recreated and the activity is added to the newly created task.

For example, if a user leaves a task for a long time, the system clears all activity outside the task root activity. When the user returns to this task again, only the root activity is stored. The system behavior is this way because after a long time, users may have abandoned their jobs before returning to the task, and started some new tasks.


You can use some activity properties to modify this behavior
1.alwaysRetainTaskState
If this property is set to "true" in the root activity of a task, then the default behavior as described above does not occur. Even after a long time, the task retains all activity in its stack.
2.clearTaskOnLaunch
If this property is set to "true" in the root activity of a task, the stack will be purged to the root activity regardless of when the user leaves and returns the task. In other words, it is in contrast to the Alwaysretaintaskstate property, where the user always returns to the initial state of the task, even if it only leaves the task for a while.
3.finishOnTaskLaunch
This attribute point is like the Cleartaskonlaunch property, but it only operates on a single activity, not the entire task. It can also cause any activity to leave, including root activity. When this property is set to "true", the activity only maintains the part of the current session in the task. If the user leaves and then returns to the task, it no longer exists.

Description of activity properties in Android (reproduced)

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.