Introduction to the Android Interface Architecture (Activity,phonewiondow,decorview)

Source: Internet
Author: User

 

in a In Android applications, the user interface is built from view and ViewGroup objects. All The subclass of View becomes " Widget", and all ViewGroup subclasses become "Layout". The combination design pattern is used between the View and the viewgroup . ViewGroup as the topmost layer of the layout container class, the layout container can also have View and viewgroup.

ViewGroup and View combination relationships such as:

ViewGroup and view inheritance relationships such as:

whenStartActivitytime, there was aSetcontentview ()method,Activityis not actually a display view, actuallyActivitycalled thePhonewindowof theSetcontentview ()method, and then load the view to put the view in thisWindowon, andActivityIn fact, when the structure is initialized,Window(Phonewindow),ActivityIt's actually a control unit, a visual human-computer interface.(Activityis not actually a display view,Viewis the real display view).

each The Activity contains a Phonewindow object,phonewindow settings decorview the root view of the application window, and all UI parts are placed in the the decorview . In the inside is familiar Titleview and contentview, usually use the Setcontentview () is the set of Contentview.

from the user's point of view, Android is a multi-window operating system, different sizes of the window area according to size, location, Z-order and whether transparency and other parameters are superimposed together and eventually presented to the user. These windows can be either from an app or from multiple apps, which can be displayed either in a flat or a different plane. In summary, the window is a hierarchical display area, each window at the bottom of the final embodiment of a rectangular buffer, these buffer is calculated to become a new Buffer, and the display system is finally delivered.

The relationship between Activity,phonewiondow,decorview is as follows:

    • Window class

located in /frameworks/base/core/java/android/view/window.java. The class is an abstract class that provides a common set of APIs for drawing Windows . It can be understood as a carrier, and various view shows on this carrier.

    • Phonewindow class

is located/frameworks/policies/base/phone/com/android/internal/policy/impl/phonewindow.java. This class inherits from theWindowclass, isWindowThe concrete implementation of the class, that is, we can draw the window by this class. Also, the class contains an internalDecorviewobject, theDectorviewobject is all app Windows(ActivityInterface)the rootView. In short,Phonewindowclass is to put aFramelayoutclass isDecorviewobject to be wrapped as the root of the application window.View, and provides a common set of window operator interfaces.

    • Decorview class

This class isPhonewindowthe inner class of the class. This class is aFramelayoutsubclass, and isPhonewindowSubclass of the class, which is the normalFramelayoutThe extension of the function, more precisely, can be said to be modified(DecorThe English name isDecoration, i.e."Retouching"the meaning), such as addingTitleBar (title bar), as welltitlebarscroll bar on the other. The Most important point is that it is the root View of all the application Windows .

Make a metaphor:

Activityis a worker, it comes to controlWindow;Windowis a display, used to display information;Viewis to display the information on the display, theseVieware overlapping layers (byInfalte ()and theAddView ()) put inWindowon the display. andLayoutinfalteris used to generateViewa tool thatXMLThe layout file is used to generateViewof raw materials

Introduction to the Android Interface Architecture (Activity,phonewiondow,decorview)

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.