The following figure shows the most basic UI block in Android.
The logical structure shown in this figure is also from the explanation of Android system principles and development points.
UI elements in Android are often described in layout. in Java source code, the findviewbyid () function obtains the handle of each view based on the ID, and convert it to the actual type for use.
Android. View. View extensions are also called Widgets. They are usually included in the Android. widget package, that is, the UI elements used in the UI elements.
These Android. View. View extensions can be used directly in applications, or they can be used again in applications.
An important extension of Android. View. view is the Android. View. viewgroup class. This class represents a set of views. The set of views can contain many subviews. The extension of the android. View. viewgroup class is a combination of multiple views, and it is also a view.
1. The extended relationship of the button class is as follows:
-Android. View. View
-Android. widget. textview
-Android. widget. Button
The button class extends the textview class. The textview class is a direct extension of the view, indicating a text area. In Android, all the UI elements with text as the main content are extended from this class.
The button class has an extension named compoundbutton (combination button), and compoundbutton has radiobutton checkbox and togglebutton (switch button, which contains two statuses ).
2. The imageview class is a direct extension of the view. It is also called an image view. It is a UI element for Android to directly display images. The image source is its core. Imageview has a variety of different ways to set the image source:
Void setimageresource (INT resid) // sets the resource ID of the image source.
Void setimageuri (URI) // sets the URI of the image source.
Void setimagebitmap (Bitmap BM) // sets a bitmap as the image source.
In addition, imageview supports scaling, cropping, and other functions.
3. imagebutton: Image button
It is easy to show a button with an image.
Note: In Android, the image button imagebutton does not have any extended relationship with the normal button.
4. viewgroup
Viewgroup1 is a view group that includes view2 and view3 in a horizontal layout;
Viewgroup2 is a view group that vertically contains view4, viewgroup3, and viewgroup4.
Viewgroup4 includes view5 and view6 in a horizontal layout.
According to the above principle, when the screen needs to contain multiple views, it must be organized in a view group.
Because the view group itself is also a view, the view group can also contain view groups.
Note: There is a major restriction here:If there is no view group, more than two views (including view groups) cannot be tied together.
The viewgroup view group has a series of extensions: adapterview, absolutelayout, framelayout, linearlayout, relativelayout, and adapterview <t extends Android. widget. Adapter>.
In Android, Some preset viewgroups can be used directly like views (such as webview), and some viewgroups have no function, it only provides various la s on the screen (such as absolutelayout, relativelayout, and framelayout)