Introduction to Android Interface Architecture (Activity, PhoneWiondow, DecorView), activitydecorview

Source: Internet
Author: User

Introduction to Android Interface Architecture (Activity, PhoneWiondow, DecorView), activitydecorview

 

 

In an Android Application, the user interface is built through the View and ViewGroup objects. The child classes of all views become "widgets", and the Child classes of all viewgroups become "Layout ". The combination design mode is used between View and ViewGroup. As the top layer of the layout container class, ViewGroup can have View and ViewGroup in the layout container.

 

The combination of ViewGroup and View is as follows:

 

The inheritance relationship between ViewGroup and View is as follows:

 

 

When an Activity is started, there is a setContentView () method. The Activity is not actually a display view. In fact, the Activity calls the setContentView () method of PhoneWindow and then loads the view, put the view on this Window, while the Activity initializes the Window (PhoneWindow) during construction, and the Activity is actually a control unit, that is, visual human-computer interaction interface (the Activity is not a display View, but a View is a real display View ).

 

 

Each Activity contains a PhoneWindow object, and PhoneWindow sets DecorView as the Root View of the application window. All UI parts are placed in DecorView. It contains the familiar TitleView and ContentView. setContentView () is the configured ContentView.

From the user's point of view, Android is a multi-window operating system. The window areas of different sizes are based on the size, position, parameters such as z-order and transparency are superimposed and finally presented to the user. These windows can be either from an application or from multiple applications. These windows can be displayed on either a plane or a different plane. All in all, the window is a hierarchical display area, and each window is eventually reflected as a rectangular Buffer at the bottom layer. These buffers are calculated and merged into a new Buffer, it is finally delivered to the Display system for Display.

 

Activity, PhoneWiondow, and DecorView relationships are as follows:

 

 

 

  • Window class

Located in/frameworks/base/core/java/android/view/Window. java. This class is an abstract class that provides a set of common APIs for drawing windows. It can be understood as a carrier, and various views are displayed on this carrier.

  • PhoneWindow class

Located in/frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindow. java. This class inherits from the Window class and is the specific implementation of the Window class, that is, we can draw a Window through this class. In addition, this class contains a DecorView object, which is the root View of all application windows (Activity interfaces. In short, the PhoneWindow class encapsulates a FrameLayout class, namely, the DecorView object, as the Root View of the application window, and provides a set of common window operation interfaces.

  • DecorView class

This class is the internal class of the PhoneWindow class. This class is a subclass of FrameLayout and a subclass of PhoneWindow. This class is used to expand the functions of common FrameLayout. More specifically, it can be called Decoration, such as adding a TitleBar and a scroll bar on the TitleBar.Most importantly, it is the root View of all application windows.

 

 

A metaphor:

Activity is a worker who controls the Window. Window is a display screen used to display information. View is the information to be displayed on the display screen, these views are stacked together (via infalte () and addView () and placed on the Window display. LayoutInfalter is a tool used to generate a View. The XML layout file is used to generate a View.

 

 

 

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.