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:
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.
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.
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.