0% found this document useful (0 votes)
4 views3 pages

Positioning in RelativeLayout XML

The document provides instructions for creating a user interface in Android using a RelativeLayout in the 'res/layout/main.xml' file. It includes XML code for positioning buttons, a TextView, and an EditText component. The layout specifies the arrangement of these components relative to each other to achieve the desired UI design.

Uploaded by

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

Positioning in RelativeLayout XML

The document provides instructions for creating a user interface in Android using a RelativeLayout in the 'res/layout/main.xml' file. It includes XML code for positioning buttons, a TextView, and an EditText component. The layout specifies the arrangement of these components relative to each other to achieve the desired UI design.

Uploaded by

amits.bhel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

RelativeLayout
Open “res/layout/[Link]” file, add components and position it via “RelativeLayout“. Read
below XML code, quite verbose to tell you where to display the component.

File : res/layout/[Link]

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="[Link]

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

<Button

android:id="@+id/btnButton1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 1"/>

<Button

android:id="@+id/btnButton2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 2"

android:layout_toRightOf="@+id/btnButton1"/>

<Button

android:id="@+id/btnButton3"
android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 3"

android:layout_below="@+id/btnButton1"/>

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/btnButton3"

android:layout_marginTop="94dp"

android:text="User :"

android:textAppearance="?android:attr/textAppearanceLarge" />

<EditText

android:id="@+id/editText1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:layout_alignTop="@+id/textView1"

android:layout_toRightOf="@+id/btnButton3" />

<Button

android:id="@+id/btnSubmit"

android:layout_width="wrap_content"

android:layout_height="wrap_content"
android:layout_alignParentRight="true"

android:layout_below="@+id/editText1"

android:text="Submit" />

</RelativeLayout>

2. Demo
See result, above XML code will generate following output.

You might also like