Hello Geeks,
In the last tutorial we have seen Creating Linear Layout.
In this tutorial we are going to learn how to create Relative Layout?
Firstly we should know what is the difference between Linear and Relative Layout?
A Relative Layout designs a powerful user interface because it eliminate nested view groups and keep our layout hierarchy flat, which improves performance.
So we can replace nested Linear Layout groups with a single Relative Layout.
A Relative Layout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent
Fig: Relative Layout
Positioning Views
Some of the many layout properties available to views in a
For example:
In the last tutorial we have seen Creating Linear Layout.
In this tutorial we are going to learn how to create Relative Layout?
Firstly we should know what is the difference between Linear and Relative Layout?
A Relative Layout designs a powerful user interface because it eliminate nested view groups and keep our layout hierarchy flat, which improves performance.
So we can replace nested Linear Layout groups with a single Relative Layout.
A Relative Layout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent
Relative Layout
area (such as aligned to the bottom, left of center).Fig: Relative Layout
Positioning Views
Some of the many layout properties available to views in a
Relative Layout
include:android:layout_alignParentTop
- If
"true"
, makes the top edge of this view match the top edge of the parent. android:layout_centerVertical
- If
"true"
, centers this child vertically within its parent. android:layout_below
- Positions the top edge of this view below the view specified with a resource ID.
android:layout_toRightOf
- Positions the left edge of this view to the right of the view specified with a resource ID.
For example:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="16dp" android:paddingRight="16dp" > <EditText android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/reminder" /> <Spinner android:id="@+id/dates" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/times" /> <Spinner android:id="@id/times" android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentRight="true" /> <Button android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/times" android:layout_alignParentRight="true" android:text="@string/done" /> </RelativeLayout>
See you guys in next tutorial for Grid View.
I simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog.Android Training placement | Android Training in chennai |Android Training in Velachery | android development course fees in chennai
ReplyDeleteRelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view)..Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more
ReplyDeleteAndroid Training in chennai | Android Training|Android Training in chennai with placement | Android Training in velachery