Skip to content

Instantly share code, notes, and snippets.

@leonguyen
Last active December 15, 2015 19:09
Show Gist options
  • Select an option

  • Save leonguyen/5309283 to your computer and use it in GitHub Desktop.

Select an option

Save leonguyen/5309283 to your computer and use it in GitHub Desktop.
Android Lab: Relative Layout - Defining an XML Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#f00"
android:gravity="center"
android:padding="25dp"
android:text="RED"
android:textColor="#000" >
</TextView>
<TextView
android:id="@+id/textView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#ffa500"
android:gravity="center"
android:padding="25dp"
android:text="ORANGE"
android:textColor="#000" >
</TextView>
<TextView
android:id="@+id/textView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#ffff00"
android:gravity="center"
android:padding="25dp"
android:text="YELLOW"
android:textColor="#000" >
</TextView>
<TextView
android:id="@+id/textView05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#00f"
android:gravity="center"
android:padding="25dp"
android:text="BLUE"
android:textColor="#fff" >
</TextView>
<TextView
android:id="@+id/textView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/TextView05"
android:background="#0f0"
android:gravity="center"
android:padding="25dp"
android:text="GREEN"
android:textColor="#000" >
</TextView>
<TextView
android:id="@+id/textView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/TextView05"
android:background="#4b0082"
android:gravity="center"
android:padding="25dp"
android:text="INDIGO"
android:textColor="#fff" >
</TextView>
<TextView
android:id="@+id/textView07"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ee82ee"
android:gravity="center"
android:padding="25dp"
android:text="VIOLET"
android:textColor="#000" >
</TextView>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment