Basic concepts of UI framework in activity

Source: Internet
Author: User

Basic concepts of UI framework in activity

Activity is an essential part of an application, providing a visual interface, UI container, and interaction with the user;

The specific acitivity is how to display these things view elements and respond to event interactions.

an activity-related concept

activity: Activity contains a window that is called in the activity's attach method by invoking the

Policymanager.makenewwindo creation;

View: The most basic UI component that represents a rectangular area on the screen;

Decorview: Is the rootview of the view in window, set the properties of Windows;

window: Represents the top-level windows, manages the display of the interface and responds to events; each activity creates a

Phonewindow object, which is an interface for activity and the entire view system to interact

WindowManager: A interface, inherited from Viewmanager. The window manager where the application process is located;

There is a implementation windowmanagerimpl;

It is mainly used to manage some of the window's states, properties, view additions, deletions, updates, window order, message collection and processing.

Viewroot : interacts with the Global window manager via the Iwindowsession interface: interface control and message response;

Activitythread : The main thread of the application, which creates the associated current activity with window;

Create an instance of the WindowManager implementation class and add the current Decoview to the WindowManager;




two. What is the relationship between Activity, window and view?
Tracking Activity's source code will find: Activity.attch (), Policymanager, Policy, Phonewindow, Mlayoutinflater.inflate () & Amp;mcontentparent.addview () This is just a simple trace process description. By tracking the source code, you can clearly see the relationship between the three of them.
Activity is like a Craftsman (Control Unit), window like a window (bearer model), a view like a grilles (display view) Layoutinflater like scissors, XML configuration like a grilles drawing.
1) An activity construct will initialize a window, which is exactly PhoneWindow2) This phonewindow has a "viewroot", the quotation mark is actually this "viewroot" is a view or ViewGroup, which is the most initial of the root views. 3) "Viewroot" through the AddView method to add a view. For example, Textview,button, etc. 4) These view events are monitored by Windowmanagerservice to accept the message and callback the activity function. such as Onclicklistener,onkeydown, etc.
2. Activity is the display view of Android? No
3. What does Layoutinflater do? What does Layoutinflater.inflater () do? Generally speaking, we do one thing with Layoutinflater: inflate. Inflate this method has a total of four forms, the purpose is to transform the layout of the XML expression into a view. This is the used to instantiate layout XML file into its corresponding View objects. It is never being used directly--use Getlayoutinflater () or Getsystemservice (String) getlayoutinflater () or Getsystemservice (String) to retrieve a, layoutinflater instance that's already hooked up to the current context and correctly con Figured for the device is running on
Three. Implementing the process Framework diagram

The creation Association process for the activity on window is as follows:


related class structure:



Hierarchical Relationship:






From for notes (Wiz)

Basic concepts of UI framework in activity

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.