RelativeLayout布局 
 android:layout_marginTop=”25dip” //顶部距离 
 android:gravity=”left” //空间布局位置 
 android:layout_marginLeft=”15dip //距离左边距 
 // 相对于给定ID控件 
 android:layout_above 将该控件的底部置于给定ID的控件之上; 
 android:layout_below 将该控件的底部置于给定ID的控件之下; 
 android:layout_toLeftOf 将该控件的右边缘与给定ID的控件左边缘对齐; 
 android:layout_toRightOf 将该控件的左边缘与给定ID的控件右边缘对齐; 
 android:layout_alignBaseline 将该控件的baseline与给定ID的baseline对齐; 
 android:layout_alignTop 将该控件的顶部边缘与给定ID的顶部边缘对齐; 
 android:layout_alignBottom 将该控件的底部边缘与给定ID的底部边缘对齐; 
 android:layout_alignLeft 将该控件的左边缘与给定ID的左边缘对齐; 
 android:layout_alignRight 将该控件的右边缘与给定ID的右边缘对齐; 
 // 相对于父组件 
 android:layout_alignParentTop 如果为true,将该控件的顶部与其父控件的顶部对齐; 
 android:layout_alignParentBottom 如果为true,将该控件的底部与其父控件的底部对齐; 
 android:layout_alignParentLeft 如果为true,将该控件的左部与其父控件的左部对齐; 
 android:layout_alignParentRight 如果为true,将该控件的右部与其父控件的右部对齐; 
 // 居中 
 android:layout_centerHorizontal 如果为true,将该控件的置于水平居中; 
 android:layout_centerVertical 如果为true,将该控件的置于垂直居中; 
 android:layout_centerInParent 如果为true,将该控件的置于父控件的中央; 
 // 指定移动像素 
 android:layout_marginTop 上偏移的值; 
 android:layout_marginBottom 下偏移的值; 
 android:layout_marginLeft   左偏移的值; 
 android:layout_marginRight   右偏移的值;android:id — 为控件指定相应的ID 
 android:text — 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串 
 android:grivity — 指定控件的基本位置,比如说居中,居右等位置这里指的是控件中的文本位置并不是控件本身。 
 android:textSize — 指定控件当中字体的大小 
 android:background — 指定该控件所使用的背景色,RGB命名法 
 android:width — 指定控件的宽度 
 android:height — 指定控件的高度 
 android:padding* — 指定控件的内边距,也就是说控件当中的内容 
 android:sigleLine — 如果设置为真的话,则控件的内容在同一行中进行显示 
 下边是相对布局属性的说明:RelativeLayout 
 android:layout_above 将该控件的底部至于给定ID控件之上 
 android:layout_below 将该控件的顶部至于给定ID的控件之下 
 android:layout_toLeftOf 将该控件的右边缘和给定ID的控件左边缘对齐 
 android:layout_toRightOf 将该控件的左边缘和给定ID的控件的右边缘对齐 
 android:layout_alignBaseline 该控件的baseline和给定ID的控件的baseline对齐 
 android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘对齐 
 android:layout_alignLeft 将该控件的左边缘与给定ID控件的左边缘对齐 
 android:layout_alignRight 将该控件的右边缘与给定ID控件的右边缘对齐 
 android:layout_alignTop 将该控件的顶部边缘与给定ID控件的顶部对齐 
 android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐 
 android:layout_alignParentLeft 如果该值为true,则将该控件左边与父控件的左边对齐 
 android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐 
 android:layout_alignParentTop 如果该值为true,则将该控件的顶部与父控件的顶部对齐 
 android:layout_centerHorizontal 如果为真,该控件将被至于水平方向的中央 
 android:layout_centerInParent 如果为真,该控件将被至于父控件水平方向和垂直方向的中央 
 android:layout_centerVertical 如果为真,该控件将被至于垂直方向的中央 
 android:layout_marginLeft此属性用来设置控件之间的间隙(控件和控件之间和内边距不同) 
 android:padding=”3dip”说明了四边的内边距是3dip

代码:
TableLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"


    tools:context="com.example.asus.test.MainActivity">

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:background="#729138"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:layout_alignParentEnd="true"

        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:layout_centerHorizontal="true"
        android:id="@+id/bt_main_jj"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:layout_centerHorizontal="true"

        android:id="@+id/ba_main_hh"
        android:layout_centerVertical="true"
        />


</RelativeLayout>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/bu_main_xiaohei"
        android:layout_margin="10dp"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="5"

        android:layout_toLeftOf="@id/bu_main_xiaohei"
        android:layout_centerVertical="true"

        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="5"

      android:layout_toRightOf="@id/bu_main_xiaohei"
        android:layout_centerVertical="true"

        />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="5"


      android:layout_alignParentBottom="true"

        />

</RelativeLayout>

android RelativeLayout 控件中心对齐_布局


好啦简单的演示就做完啦