android window mechanism analysis------UI Management System

Source: Internet
Author: User

Activity can be seen as a human-computer interface for the entire Android system, which provides a window to draw the UI, and each activity starts with a content view that we need to set as the UI contents of the activity. This process is accomplished through the Setcontentview () method.

As we all know, the concept of the view is enhanced in Android, mainly in view management, Android view in 2 forms, a single view and multiple view composed of ViewGroup. Content view exists in the form of viewgroup, which means that multiple view can be added to an Activity window, which allows the android window system to diversify its UI. The content view set for the Activity window when the activity starts is parsed from the XML file, so how does Android manage the Contentview, and what about its internal implementation logic?

Before analyzing, we first give a hierarchical relationship between the activity's window and the view system, which is the condition after the activity is set to Contentview.

Such as.



Here are the meanings and roles of each level

1.1 Phonewindow

Phonewindow is the most basic window system in Android, and each activity creates a Phonewindow object, which is an interface for activity and the entire view system to interact.


1.2 Decorview

Decorview is the ancestor of the current activity all view, it does not present to the user anything, it mainly has the following several functions, may not complete:

A. Dispatch viewroot distribution of key, touch, trackball and other external events;

B. Decorview has a direct sub-view, which we call System Layout, which is parsed from the layout.xml of the system and contains the current UI style, such as whether it has a title, whether it has a process bar, and so on. These properties can be called window decorations.

C. As a bridge between Phonewindow and Viewroot, Viewroot sets the window properties by Decorview.


1.3 System Layout

Currently Android based on user needs to preset a few UI styles, through Phonewindow by parsing the preset layout.xml to get the layout containing the different window decorations, we call system layout, We have added this system layout to Decorview, and currently Android offers 8 system layout, such as.

The default style can be set by the Phonewindow method Requestfeature (), and it is important to note that this method needs to be called before the Setcontentview () method call.


1.4 Content Parent

Content parent This ViewGroup object is really the contentview of the parent, our Contentview finally found the host, it actually corresponds to the system layout in the ID "content" One of the framelayout. This Framelayout object includes the layout of our activity (each system layout will have a framelayout with the id "content").



1.5 Activity Layout

This activitylayout is the contentview that we need to set to the window, and now we find that it is very low, and this part is the UI part that interacts with the user, and the layers on it do not respond to and accomplish what the user input is expected to achieve.

android window mechanism analysis------UI Management System

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.