RelativeLayout Basic Example

Relative Layout  Basic  Example

Android RelativeLayout Example

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android
:layout_width="match_parent"
android
:layout_height="match_parent"
android
:orientation="vertical"
android
:padding="10dp">

<Button
android
:id="@+id/button"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_alignParentTop="true"
android
:layout_centerHorizontal="true"
android
:text="Button1" />

<Button
android
:id="@+id/button2"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_alignParentRight="true"
android
:layout_centerVertical="true"
android
:text="Button2" />

<Button
android
:id="@+id/button3"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_alignParentLeft="true"
android
:layout_centerVertical="true"
android
:text="Button3" />

<Button
android
:id="@+id/button4"
android
:layout_width="match_parent"
android
:layout_height="wrap_content"
android
:layout_alignParentBottom="true"
android
:text="Button5" />

<Button
android
:id="@+id/button5"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_alignBottom="@+id/button2"
android
:layout_centerHorizontal="true"
android
:text="Button4" />

<Button
android
:id="@+id/button6"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_above="@+id/button4"
android
:layout_centerHorizontal="true"
android
:text="Button6" />

<Button
android
:id="@+id/button7"
android
:layout_width="wrap_content"
android
:layout_height="wrap_content"
android
:layout_alignBottom="@+id/button"
android
:layout_toEndOf="@+id/button"
android
:layout_toRightOf="@+id/button"
android
:text="Button7" />

</RelativeLayout>

Example 2:



Code:

<?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="wrap_content">

<TextView android:id="@+id/label" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Enter email address" />

<EditText android:id="@+id/inputEmail" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/label" />

<Button android:id="@+id/btnLogin" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@id/inputEmail"
android:layout_alignParentLeft="true" android:layout_marginRight="10px"
android:text="Login" />

<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@id/btnLogin"
android:layout_alignTop="@id/btnLogin" android:text="Cancel" />

<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:text="Register"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
RelativeLayout Basic Example RelativeLayout Basic Example Reviewed by Anonymous on December 25, 2015 Rating: 5

No comments:

Java Ternary Operator

Java Ternary Operator Java ternary operator is the only conditional operator that takes three operands. Java ternary operator is a one l...

Powered by Blogger.