Android Window Mechanism Analysis and UI management system, androidui

Source: Internet
Author: User

Android Window Mechanism Analysis and UI management system, androidui
Class graph relationship

Before reading the window mechanism of Android, let's take a look at itsMain class graph relationshipsAndDependency and call Relationship Between Layers  

  

 

1. The window is displayed in the current android system.PhoneWindow

(Frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindow. java );

2. The implementation entity of WindowManager is WindowManagerImpl. java.

(Frameworks/base/core/java/android/view/WindowManagerImpl. java );

 

Hierarchical relationship

It mainly describes the hierarchical relationship of the window system. The figure shows that WindowManager runs in Application process,WindowManagerService is run in system_serverThe communication between the two is implemented through the Session Layer IWindowSession.

  

 

ViewRoot class

  ViewRoot is a bridge between the GUI management system and the GUI presentation system.According to the definition of ViewRoot, we found that it is not a View type,WhileIs a Handler.

  Main functionsAs follows:

After the ContentView settings of the Activity are completed, the following work is to prepare for display. The main work to prepare for display is to establish the connection between the Application and WindowManagerService, the first step is to add the previously involved DecorView to WindowManager.DecorView contains the GUI of the entire ActivitySo we only need to hand over the DecorView to WindowManager.

UI Management System

 Activity can be viewed as a human-machine interface of the entire android system.It provides a window to draw the UI. When every Activity is started, we need to set a Content view for it as the UI Content presented by the Activity, this process is implemented through the setContentView () method.

As we all know,The concept of view is enhanced in the android system, mainly reflected in the management of view.,The view in Android has two forms: a single View and a ViewGroup composed of multiple views.Content view exists in the form of ViewGroup. That is to say, you can add multiple views in an Activity window, thus realizing diversified UI of the Android window system. When the activity starts, the Content view set for the activity window is parsed from the xml file.How does android manage this ContentView and its internal implementation logic?

Before performing the analysis, first readHierarchical relationship between window and view systems of an ActivityThe hierarchical relationship is the State after the ContentView is set for the Activity.

Meanings and functions of different levels

PhoneWindow

  PhoneWindow is the most basic Window System in Android. Each Activity creates a PhoneWindow object, which is an interface for interaction between the Activity and the entire View system.

DecorView

  DecorView is the ancestor of all views of the current Activity.It does not present anything to the user.

It mainly includes the following:Function, May not be complete:

System Layout

Currently, android has preset several UI styles based on user requirements, and uses PhoneWindow to parse the preset layout. xml to get layout that contains different Window decorations. We call it System Layout. we add this System Layout to DecorView. Currently, android provides eight types of System Layout.

You can use the PhoneWindow method to set the default style.RequestFeature ()You must note that this method must be called before the setContentView () method is called.

  

Content Parent

Content Parent: The ViewGroup object is the real ContentView parent. ContentView finally finds the host, which corresponds to a FrameLayout with the id "content" in System Layout. This FrameLayout object includes the layout of the Activity (each System Layout will have a FrameLayout with the id of "content ).

Activity Layout

This ActivityLayout is the ContentView we need to set to the window. Now we find that its position is very low, and this part is the UI part of the interaction with the user, the preceding layers cannot respond to and complete the user input expectations.

 

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.