<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/relative_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:"/>
<EditText
android:id="@+id/relative_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/relative_label"/>
<Button
android:id="@+id/relative_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/relative_entry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:text="OK" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/relative_ok"
android:layout_alignTop="@id/relative_ok"
android:text="Cancel" />
</RelativeLayout>
</pre><pre name="code" class="java">
android:layout_above 将控件的底部至于给定的id控件之上
<pre name="code" class="java">android:layout_above="@id/xxx"
<pre name="code" class="java">android:layout_below 将控件的底部至于给定的id控件之下
android:layout_toLeftor将控件的右边缘和给定的id的控件的左边缘对齐
<pre name="code" class="java">android:layout_toRightor将控件的右边缘和给定的id的控件的右边缘对齐
</pre><pre name="code" class="java"><pre name="code" class="java">android:layout_alignBaseline 将控件的baseline和给定的id的控件的baseline对齐
<pre name="code" class="java">android:layout_alignBottom 将控件的底部边缘与给定的id控件的底部对齐
<pre name="code" class="java">android:layout_alignLeft 将控件的左边缘与给定id控件的左边缘对齐
<pre name="code" class="java">android:layout_alignRight 将控件的右边缘与给定id控件的右边缘对齐
android:layout_alignParentBottom 如果值为true,则将控件的底部与父控件的底部对齐
android:layout_alignParentLeft 如果值为true,则将控件的左边缘与父控件的左边缘对齐
android:layout_alignParentRight 如果值为true,则将控件的右边缘与父控件的右边缘对齐
android:layout_alignParentTop 如果值为true,则将控件的顶部与父控件的顶部对齐
<span style="font-size:10px;"><span style="font-family: 宋体; line-height: 24px;">
</span></span>
<span style="font-size:10px;"><span style="font-family: 宋体; line-height: 24px;">例:Android:layout_alignParetBottom=true</span></span>
<span style="font-size:10px;"><span style="font-family: 宋体; line-height: 24px;">android:layout_centerHorizontal ——> <wbr></wbr></span><span style="font-family: 宋体; line-height: 24px;">如果值为<span lang="EN-US">true,</span>则该控件在其父控件范围内水平居中<span lang="EN-US">
android:layout_centerInparent ——> <wbr></wbr></span>如果值为<span lang="EN-US">true,</span>则该控件在其父控件范围内垂直且水平居中<span lang="EN-US">
android:layout_centerVertical ——></span> 如果值为<span lang="EN-US">true,</span>则该控件在其父控件范围内垂直居中</span></span>