Views and View Groups

The basic building block of a graphical layout is a view. Each view is described by a View Object, which is responsible for drawing a rectangular area and handling events in that area.The View is a base class for objects that interact with the user; they are called widgets. Examples of widgets are buttons and check boxes.

A ViewGroup Object is a type of View that acts as a container to hold multiple Views (or other ViewGroups). For example, a ViewGroup can hold a vertical or horizontal placement of views and widgets, as shown in Figure 4.1.The ViewGroup is a base class for screen layouts.

Your contact information

Horizontal Vi owGroup

Figure 4.1 View example that contains ViewsGroups and widgets.

The layout defines the user interface elements, their positions, and their actions. It can be specified from either XML or Java. Most often, an initial base layout is declared in XML and any run-time changes are handled in Java.This combines the ease of developing the overall position ofView and ViewGroup Objects using XML and the flexibility to change any component within the application using Java.

Another benefit of separating the XML layout from the Java activity is that the same Android application can produce a different behavior depending on the screen orientation, type of device (such as phone versus tablet), and locale (such as English versus Chi-nese).These customizations can be abstracted into various XML resource files without cluttering the underlying activity.

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment