Android UI Framework Overview

Source: Internet
Author: User
Tags thread class
The true logic of Android apps


App UI Component Hierarchy

Most of the UI components in Android are stored in Android.widget packages and their children, android.view packages, and their child packages, all of which are inherited from The View class , The view class also has an important subclass of ViewGroup, so it has a view feature, but it is primarily used as a container for view, which sees the view as its own child and manages its child view. Of course its children can also be viewgroup types. ViewGroup is often used as a container for other components.

In Android, view has a broader meaning than views, and it contains user interaction and display, more like windows in the windows-based operating system. The ViewGroup (root node) and its children (view and ViewGroup) Form a hierarchical structure in a tree structure, theview class has the ability to accept and process messages , and the information generated by the Android system will be in these viewgroup and View passed between. All of the app's interface components are the logic of the following diagram:


A more detailed structure can refer to:



The subclass TextView of view is the most noteworthy:


the App UI interface shows the logical principle of the screen:

When Activitythread receives AMS to send a start activity, it creates the specified Activity object. The activity creates the Phonewindow class-decorview class-Create the corresponding view or ViewGroup. Once created, the activity needs to display the created interface to the screen, then call the WindowManager class, which creates a Viewroot object that actually creates the Viewroot class and the W class, and after creating the Viewroot object, WindowManager calls the WMS-provided transport interface to complete adding a window and displays it to the screen. main logical process:

Activity Setcontentview->window Setcontentview->phonewindow Setcontentview-->phonewindow installdecor-– >phonewindow Generatelayout-->phonewindow mlayoutinflater.inflate (Layoutresid, mContentParent);

The activity class has an implementation Phonewindow class of the Window abstract class, which has an internal class Decorview, inherits from Framelayout, and adds a root layout to the Decorview container, which contains a root layout with an ID of Contnet's framelayout content layout, our activity-loaded layout XML was finally added to the framelayout layout with ID content. Use a diagram to describe the following:


Introduction to processing logical classes:

Activitythread: This class is the main thread class for the application, all APK programs have and only one Activitythread class, and the entry for the program is the static main function in that class, The thread on which the Activitythread is located is either the UI thread or the main path.

Activity: This class is the smallest operating unit of the APK program for the APK program, in other words, the smallest unit class in which the main thread dynamically loads executable code, and a APK program can contain multiple active objects. Activitythread the main class selects which activity objects are dynamically loaded based on user actions.

Phonewindow: This class inherits from the window class, and the Phonewindow class contains a Decorview object, and Decorview's parent class is framelayout, so the Phonewindow contains a view object. and provides a set of common window Operation APIs.

Window: This class provides a common set of window operation APIs, where windows are only client-side, and the windows that WMS manages are not window classes, but a view or ViewGroup class, For the Phonewindow class, it is the Decorview class contained within it. Window is an abstract type.

Decorview: This class is a framelayout subclass and is an internal class in Phonewindow. Decorview is a regular framelayout, such as adding a generic tilebar, and responding to specific key messages.

When VIEWROOT:WMS manages client windows, it is necessary to notify the client of some kind of action, which is done through an IPC call, and after the client window receives the IPC call, it converts the call to a local asynchronous call, implemented by using handler, Viewroot is inherited from Handler, whose main function is to convert WMS's IPC call into a local asynchronous call. Viewroot This class plays an intermediary role in the Android UI structure, Connected to Phonewindow and Windowmanagerservice.windowmanagerservice, we know that it reads all the events, keyboard events, trackball events, and so on in the Android system, and how it is distributed to each activity. is through this viewroot.

WindowManager class: The client wants to create a window, and the task of creating a window is done by the WMS, the WindowManager class is like a department manager, who has the need to tell it, and it interacts with WMS, the client cannot directly interact with WMS.


Main reference:

https://blog.csdn.net/a910626/article/details/51553589

Https://www.cnblogs.com/aademeng/articles/6539190.html

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.