Android Layout Layout A layout defines the visual

  • Slides: 17
Download presentation
Android Layout

Android Layout

Layout • A layout defines the visual structure for a user interface, such as

Layout • A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. • Layout. xml File Parameters • android: layout_width • android: layout_height • android: orientation

Layouts & Views • Linear Layout • Relative Layout • Frame Layout • Table

Layouts & Views • Linear Layout • Relative Layout • Frame Layout • Table Layout • List View • Grid View

Linear Layout • Linear layout is used to place one element on each line.

Linear Layout • Linear layout is used to place one element on each line. • All the elements will be place in an orderly top-to-bottom fashion • It is a common layout that arranges in vertical or horizontal order, via orientation attribute.

Linear Layout It aligns all children in either vertically or horizontally.

Linear Layout It aligns all children in either vertically or horizontally.

Relative Layout • Relative layout is used to specify the position of the elements

Relative Layout • Relative layout is used to specify the position of the elements in relation to other elements, or in relation to the parent container. • This layout let you position your component base on the nearby (relative or sibling) component’s position. It’s the most flexible layout, that allow you to position your component to display in anywhere you want

Relative Layout - Example • It enables you to specify how child views are

Relative Layout - Example • It enables you to specify how child views are positioned relative to each other. • The position of each view can be specified as relative to sibling elements or relative to the parent.

Frame Layout • Frame. Layout is one of the useful layouts provided by android

Frame Layout • Frame. Layout is one of the useful layouts provided by android system, which allows User Interface widgets to be overlapped with each other. • It’s used in cases such as placing a Text. View over an Image. View. This becomes quite difficult to implement using Linear. Layout or Relative. Layout since they place widgets adjacent to each other. • Multiple children can be organized in a Frame. Layout and control their position within the Frame. Layout by assigning gravity to each children

Frame Layout - Example

Frame Layout - Example

Table Layout • It arranges groups of views into rows and columns. • <Table.

Table Layout • It arranges groups of views into rows and columns. • <Table. Row> element - build a row in the table. • Each row has zero or more cells • each cell can hold one View object.

Lab Exercise • For Each Layout • Create a Page ( with Proper Data)

Lab Exercise • For Each Layout • Create a Page ( with Proper Data) • Execute the app in your emulator or Mobile • Take a Screen shot

Radio Button

Radio Button

Image Button

Image Button

List View • List view is a view group that displays a list of

List View • List view is a view group that displays a list of scrollable items. • The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list

List View - Example

List View - Example

Grid View • Grid. View layout in one of the most useful layouts in

Grid View • Grid. View layout in one of the most useful layouts in android. • Gridview is mainly useful when we want show data in grid layout like displaying images or icons in a grid manner • It is a View. Group that displays items in a two-dimensional, scrollable grid. • The grid items are automatically inserted to the layout using a List. Adapter

Grid View - Example

Grid View - Example