[Development Diary of Android in a row from scratch] (13th) -- Analysis of Android controls, and introduction to android

Source: Internet
Author: User

[Development Diary of Android in a row from scratch] (13th) -- Analysis of Android controls, and introduction to android

Android controls are derived from android. view. view class, in android. the widget package defines a large number of system controls for developers to use. developers can also derive custom controls from the View class and its subclass.

 

I. Android Control Structure

Android has an important class of controls, called container controls. They are derived from the android. View. ViewGroup subclass of view. Each container control can exist as a parent control, which contains several child controls. Each child control occupies a region of its parent control and is managed and dominated by the parent control.

 

 

The relationship between controls in the interactive interface is intuitive and extremely complex. Therefore, Android abstracts the links between control objects into a tree structure, this simplifies the relationship between controls-each control is only controlled by its parent control, but not by other controls. To ensure the integrity of the control, Android adds a unified interactive event management object ViewParent to the Control tree, which can schedule the changes of the Control tree as a whole, this avoids local communication between control objects and greatly reduces the coupling between control objects.

In the Android control, interactive events are all propagated from top to bottom along the control tree. After the parent control receives an interactive event, it first determines the target control object of the event. If it is needed, it intercepts the event for processing, otherwise, the system tries to distribute the event to the corresponding sub-control and recursively transmits the event level by level until the event is processed or ignored. In Android, View defines a series of event functions to receive and process various types of interactive events, such as through View. the onKeyDown function can receive the user's key operations, onTouchEvent can get the user's touch screen related events, and so on. The child controls of each View class can reload these functions to process the events they need.

2. Control Properties of Android

Each Android control has certain attributes, which are used to represent the basic features of the control object. These attributes are defined in the View class.

3. Android Window Mechanism

The so-called window mechanism means that Android adopts the implementation mode based on window registration to transfer the user-interface interaction to the corresponding control. You may be familiar with interface development in c ++ and java.

The core of the window mechanism is the window Management Service (WindowManagerService), which is one of the core services of the Android system and runs in an independent thread of the core process of the system. It is responsible for managing the control tree of the interactive interface and converting user operations into interactive events and passing them to the current interface.

 

 

Iv. Basic Android controls

 

 

Controls are the basic unit for building interfaces. To help better construct the interface, Android provides a large number of basic controls. Developers can develop interactive interfaces faster and better only by understanding the features and usage of these controls. Next, I will introduce the important controls in Android one by one, and attach simple operation code.

 

 

==========================================================

Author: cpacm
(Http://www.cnblogs.com/cpacm/p/3954139.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.