Mobile Applications Lecture 3 - User Interface (I)
Mobile Applications Lecture 3 - User Interface (I)
Lecture 3 –
User Interface
Part(I)
Activity Lifecycle
UI Layouts
Types
Attributes
Objects Identification
UI Controls
UI Elements
Creation
Activity
Lifecycle
UI Layouts
UI Layouts
Android Layout Types
Linear Layout – a view group that aligns all children in a single direction,
vertically or horizontally.
Relative Layout – a view group that displays child views in relative positions.
Table Layout – a view that groups views into rows and columns.
Absolute Layout – enables you to specify the exact location of its children.
Frame Layout – a placeholder on screen that you can use to display a
single view.
List View – a view group that displays a list of scrollable items.
Grid View – a ViewGroup that displays items in a two-dimensional, scrollable
grid.
Web View – used to display online content in your activity.
Android Layout Attributes
Each layout has a set of attributes which define the visual properties of that
layout.
ID
Width, height
Margins top, bottom, left, right
Wrap_content
Match_parent
X coordinate, y coordinate
Padding top, bottom, left, right
Linear Layout
android: gravity, represents gravity in each cell like center, bottom, top, left
etc.
android: columnWidth, used to specify width of column for each cell.
android: horizontalSpacing, specify horizontal space between columns of
grid.
android: verticalSpacing, used to specify vertical space between rows of
grid.
android: numColumns, specify number of columns to show.
Grid View
UI Controls
TextView ToggleButton
EditText ProgressBar
Button Spinner
ImageButton TimePicker
Checkbox DatePicker
RadioButton
RadioGroup
Object Identification
a view object may have a unique ID assigned to it which will identify the
View uniquely within the tree.
To create an instance of the Control object and capture it from the layout,
use the following: