0% found this document useful (0 votes)
10 views12 pages

Chap3mad Relative Layout

Chapter 3 discusses RelativeLayout, a view group in Android that positions child views relative to each other or the parent. It outlines important attributes for RelativeLayout, such as android:id, android:gravity, and various layout parameters that control the positioning of views. The chapter provides detailed descriptions of attributes that allow for precise alignment and positioning of elements within the layout.

Uploaded by

tharforever97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views12 pages

Chap3mad Relative Layout

Chapter 3 discusses RelativeLayout, a view group in Android that positions child views relative to each other or the parent. It outlines important attributes for RelativeLayout, such as android:id, android:gravity, and various layout parameters that control the positioning of views. The chapter provides detailed descriptions of attributes that allow for precise alignment and positioning of elements within the layout.

Uploaded by

tharforever97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CHAPTER NO : 3

UI COMPONENTS AND
LAYOUTS
Relative Layout
 RelativeLayout is a view group that
displays child views in relative positions.
 Android RelativeLayout 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.
RelativeLayout Attributes
 Following are the important attributes specific to

RelativeLayout −
1. android:id
 This is the ID which uniquely identifies the layout.

2. android:gravity
 This specifies how an object should position its

content, on both the X and Y axes. Possible values


are top, bottom, left, right, center, center_vertical,
center_horizontal etc.
3. android:ignoreGravity
 This indicates what view should not be affected by

gravity.
 Using RelativeLayout, you can align two elements by
right border, or make one below another, centered in
the screen, centered left, and so on.
 By default, all child views are drawn at the top-left of

the layout, so you must define the position of each


view using the various layout properties available from
RelativeLayout.LayoutParams and few of the important
attributes are given below −
1. android:layout_above
 Positions the bottom edge of this view above the given

anchor view ID and must be a reference to another


resource, in the form "@[+][package:]type:name"
2. android:layout_alignBottom
 Makes the bottom edge of this view match the

bottom edge of the given anchor view ID and


must be a reference to another resource, in
the form "@[+][package:]type:name".
3. android:layout_alignLeft
 Makes the left edge of this view match the left

edge of the given anchor view ID and must be


a reference to another resource, in the form
"@[+][package:]type:name".
4. android:layout_alignParentBottom
 If true, makes the bottom edge of this view match

the bottom edge of the parent. Must be a boolean


value, either "true" or "false".
5. android:layout_alignParentEnd
 If true, makes the end edge of this view match the

end edge of the parent. Must be a boolean value,


either "true" or "false"
6. android:layout_alignParentLeft
 If true, makes the left edge of this view match the

left edge of the parent. Must be a boolean value,


either "true" or "false".
7. android:layout_alignParentRight
 If true, makes the right edge of this view match the

right edge of the parent. Must be a boolean value,


either "true" or "false".
8. android:layout_alignParentStart
 If true, makes the start edge of this view match the

start edge of the parent. Must be a boolean value,


either "true" or "false".
9. android:layout_alignParentTop
 If true, makes the top edge of this view match the

top edge of the parent. Must be a boolean value,


either "true" or "false".
10. android:layout_alignRight
 Makes the right edge of this view match the right edge

of the given anchor view ID and must be a reference


to another resource, in the form "@[+]
[package:]type:name".
11. android:layout_alignStart
 Makes the start edge of this view match the start edge

of the given anchor view ID and must be a reference


to another resource, in the form "@[+]
[package:]type:name".
12.android:layout_alignTop
 Makes the top edge of this view match the top edge of

the given anchor view ID and must be a reference to


another resource, in the form "@[+]
13. android:layout_below
 Positions the top edge of this view below the given

anchor view ID and must be a reference to another


resource, in the form "@[+][package:]type:name".
14. android:layout_centerHorizontal
 If true, centers this child horizontally within its

parent. Must be a boolean value, either "true" or


"false".
15. android:layout_centerInParent
 If true, centers this child horizontally and vertically

within its parent. Must be a boolean value, either


"true" or "false".
16. android:layout_centerVertical
 If true, centers this child vertically within its parent.

Must be a boolean value, either "true" or "false".


17.android:layout_toEndOf
 Positions the start edge of this view to the end of the

given anchor view ID and must be a reference to


another resource, in the form "@[+]
[package:]type:name".
18.android:layout_toLeftOf
 Positions the right edge of this view to the left of the

given anchor view ID and must be a reference to


another resource, in the form "@[+]
[package:]type:name".
19. android:layout_toRightOf
 Positions the left edge of this view to the

right of the given anchor view ID and


must be a reference to another resource,
in the form "@[+][package:]type:name".
20. android:layout_toStartOf
 Positions the end edge of this view to the

start of the given anchor view ID and


must be a reference to another resource,
in the form "@[+][package:]type:name".

You might also like