Relationship Between Activity Window View ViewGroup in Android

Source: Internet
Author: User

Relationship Between Activity Window View ViewGroup in Android

Activity: one of the four main components of Android, used to display an interface for interacting with users

---- Display interface

---- Interaction with users

Activity is equivalent to a controller and is responsible for calling business methods. Simple services can be processed directly in the Activity.

Activity displays the interface by using the setContentView (resource location. resource type. Resource) method of the Window object.

You can use the View operation interface.

When interacting with users, capture events through views, and pass messages through WindowManagerService (the current control and event type ). The Android Framework calls back the corresponding Activity method to achieve interaction with users.

 

Window: A Window in Android, indicating a top-level Window, that is, the main Window. Each main Window has a view, which is called DecorView ), it is the top-level View of the main window (DecorView must be a layout container because it must accommodate other views ). When the Activity calls setContentView (), it actually calls

The setContentView () method of the Window object. Execute this method and add the User-Defined View to the DecorView to display the View.

 

View: A View is the basic building block of a user interface component. It occupies a rectangular area on the screen and is the base class of all UI controls, such as a button or text box. View is responsible for graphic interface rendering and event processing.

Android has provided us with a series of standard UI controls for our direct use. At the same time, we can also implement our custom UI controls by inheriting to the View or View subclass.

 

ViewGroup: view group in Android. Contains multiple views, or ViewGroup.

ViewGroup is a special View that can accommodate other views (child controls). It is a base class for layout and View containers.

* ViewGroup. LayoutParams:

Android: layout_width (wrap_content, match_parent, fill_parent)

Android: layout_height (wrap_content, match_parent, fill_parent)

* Common ViewGroup Methods

AddView (): Add View to View group

RemoveView (): Remove View from View group

GetChildCount: obtains the number of child controls in the view group.

GetChildAt (): Get a specific sub-control

 

In Android, ViewGroup is a subclass of View, and layout manager is a subclass of ViewGroup.

 

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.