android 相对布局RelativeLayout

相对布局:根据所设置的参照控件来进行布局,设置的参考控件可以是父控件也可以是其他子控件
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="中间的按钮,很长很长很长" >
        </Button>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/button1"      控件的相对位置
            android:layout_alignLeft="@id/button1"
            android:text="上面的按钮" >
        </Button>

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignRight="@id/button1"
            android:layout_below="@id/button1"
            android:text="下面的按钮" >
        </Button>
    </RelativeLayout>

你可能感兴趣的:(andorid)