The relationship between the View class and the viewgroup class

Source: Internet
Author: User

In Android development, the android UI is composed of view and viewgroup and Their Derived classes. View is the base class of all UI components, and viewgroup is the container that holds these components, which is derived from view.

A viewgroup as a container can contain a view as a leaf node or a lower-level child viewgroup. A child viewgroup can also contain the view and viewgroup of the leaf node on the next layer. In fact, this flexible view hierarchy can form a very complex UI layout. developers can design and develop very exquisite UI interfaces accordingly.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4D/4A/wKiom1RPCrCiJ3YCAACCJpQvLHA011.jpg "Title =" .png "alt =" wkiom1rpcrcij3ycaaccjpqvlha011.jpg "/>

Generally, the UI interfaces for developing Android applications do not directly use view and viewgroup, but use the derived classes of these two base classes.


The direct subclass derived from view includes analogclock, imageview, keyboardview, progressbar, surfaceview, textview, viewgroup, and viewstub.


Indirect subclasses derived from view include abslistview, absseekbar, absspinner, cosine, adapterview <t extends adapter>, adapterviewanimator, cosine, appwidgethostview, autocompletetextview, button, calendarview, checkbox, checkedtextview, chronometer, compoundbutton,


The direct subclass derived from viewgroup includes: absolutelayout, adapterview <t extends adapter>, fragmentbreadcrumbs, framelayout, linearlayout, relativelayout, and slidingdrawer.


Indirect subclasses derived from viewgroup include: abslistview, absspinner, adapterviewanimator, adapterviewflipper, appwidgethostview, calendarview, datepicker, dialerfilter, gallery, gallery, layout, gridview, layout, imageswitcher, listview, it is particularly pointed out that imageview is a common class for layout UIS with image effects, surfaceview is a special and important class used for game development compared with general views (in-depth analysis of the principle will be conducted in the future), while absolutelayout, framelayout, linearlayout, relativelayout viewgroups Directly subclass is the most basic layout element in the android UI layout.

It is worth mentioning that all the above base classes and derived classes are standard system classes integrated at the android framework layer. In application development, developers can directly reference these system classes and their APIs in the SDK. But in fact, in many scenarios of UI development, using these System Classes directly cannot meet the needs of application development. For example, if you want to use imageview to load an image by default, but you want to change the image processing effect when you click this view, you cannot directly use imageview, in this case, we can reload imageview and ondraw and other methods in the new Child control to achieve our custom effect. This subclass method derived from the system class is generally called a custom control. Custom controls can be laid out and instantiated in XML and our java files like standard view controls, but the complete package name and class name must be specified during layout. In fact, the use of custom controls is an essential basic usage for Android development and a basic skill that must be mastered.


This article is from the "zsls" blog, please be sure to keep this source http://qqianwan.blog.51cto.com/8015812/1568732

The relationship between the View class and the viewgroup class

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.