android 相对布局RelativeLayout
<pre name="code" class="html"><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"
tools:context="com.example.linearlayouttest.MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/bn1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button1"
android:layout_alignStart="@id/button1"
android:text="@string/bn2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/button1"
android:layout_alignBaseline="@id/button1"
android:text="@string/bn3" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button1"
android:layout_alignStart="@id/button1"
android:text="@string/bn4" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/button1"
android:layout_alignBaseline="@id/button1"
android:text="@string/bn5" />
</RelativeLayout>
中间用到了
android:layout_toStartOf="@id/button1" 和 android:layout_toEndOf="@id/button1"
相当于 layout_toLeftOf 和 layout_toRightOf