13

Layouts in android

Embed Size (px)

Citation preview

Page 1: Layouts in android
Page 2: Layouts in android

In this Section

• Introduction to Layouts in Android• Types of Layouts

Layouts in Android

Page 3: Layouts in android

Layouts in Android

• Layouts define the arrangement of views.

• Android layouts are defined mostly in XML.

• Various properties of Layouts can be set using XML attributes.

Layouts in Android

Page 4: Layouts in android

Types Of Layout

• LinearLayout• RelativeLayout• FrameLayout• TableLayout

Layouts in Android

Page 5: Layouts in android

LinearLayout Used to align views horizontally or

vertically. Use android:orientation attribute to

define the orientation.

LinearLayout

Page 6: Layouts in android

LinearLayout Example

Page 7: Layouts in android

Examples

Page 8: Layouts in android

RelativeLayout

Used to arrange views in positions relative to other views or Parent Views/layouts.

Page 9: Layouts in android

Relative Layout attributes layout:toLeftOf layout:toRightOf layout:below layout:above layout:alignParentTop layout:alignParentBottom layout:alignParentLeft layout:alignParentBottom

and more…….

Page 10: Layouts in android

FrameLayout Used to display Single child view. It is useful when we have to display a

single item so that it scales properly in different screen sizes.

Page 11: Layouts in android

TableLayout Used to arrange views in rows and

columns TableRow element can be used to define

rows. android:layout_span attributes is used

to span views across columns

Page 12: Layouts in android

TableLayout Example