introduction to view,control,layout
TRANSCRIPT
Android development
Android User Interface Design
User Interface Screen Elements
Most Android applications need some form of user interface. We develop these interfaces with elements available within the Android Software Development Kit (SDK). Some of these elements display information to the user, whereas others are input controls that can be used to gather information from the user.
Introducing Android Views and Layouts
Before we can design User Interface Screen for our application , we need to understand a few terms. These are:1. VIEWS and VIEWGROUPS2. CONTROLS3. LAYOUTS
View And ViewGroup• All user interface elements in an Android app are built
using View and ViewGroup objects. • A View is an object that draws something on the screen
that the user can interact with. • A ViewGroup is an object that holds other
View (and ViewGroup) objects in order to define the layout of the interface.
• Android provides a collection of both View and ViewGroup subclasses that offer you common input controls (such as buttons and text fields) and various layout models (such as a linear or relative layout).
View
• The Android SDK has a Java packaged named android.view.
• This package contains a number of interfaces and classes related to drawing on the screen.
• It contains a class called View .• The View class serves as the base class for nearly
all the user interface controls and layouts within the Android SDK
• It represents a rectangular portion of the screen.
What is “Control” ?
• The Android SDK contains a Java package named android.widget.
• When we refer to controls, we are typically referring to a class within this package.
• The Android SDK includes classes to draw most common objects, including TextView, EditText, and Button classes.
• As mentioned previously, all controls are typically derived from the View class.
What is “Control” ?
• Our layout resource files are composed of different user interface controls. Some are static, and we don’t need to work with them programmatically.
• Others we’ll want to be able to access and modify in our Java code.
• Each control we want to be able to access programmatically must have a unique identifier specified using the android:id attribute.
• We use this identifier to access the control with the findViewById() method in our Activity class.
What is “Layout” ?• One special type of control found within the android.widget
package is called a layout. • A layout control is still a View object, but it doesn’t actually
draw anything specific on the screen.• Instead, it is a parent container for organizing other controls
(children). • Layout controls determine how and where on the screen
child controls are drawn. • Each type of layout control draws its children using particular
rules. For instance, the LinearLayout control draws its child controls in a single horizontal row or a single vertical column.