相对布局是相对与父容器或者兄弟组件等,进行布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:id="@+id/one"
android:layout_toRightOf="@id/two"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/one"
android:layout_toRightOf="@id/two"
android:layout_width="200dp"
android:layout_height="200dp"
android:text="1"
android:textSize="150dp"
android:gravity="center"
android:background="#ff1323"
/>
<TextView
android:id="@+id/two"
android:layout_width="200dp"
android:layout_height="200dp"
android:text="2"
android:textSize="150dp"
android:gravity="center"
android:background="#ff3"
/>
<TextView
android:id="@+id/three"
android:layout_toRightOf="@id/one"
android:layout_width="200dp"
android:text="3"
android:textSize="150dp"
android:gravity="center"
android:layout_height="200dp"
android:background="#cd526879"
/>
RelativeLayout>
剩下的还有许多参数,基本上就是修改参数
比如在父元素的右边
android:layout_alignParentRight="true"