相对布局
一、相对布局
- 相对布局:指按照组件之间的相对位置来进行布局。如某个组件在另一个组件的左边、右边、上方或下方等。
- 相对布局标志——
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"属性列表>
</RelativeLayout>
图片放置在中心——
android:layout_centerInParent="true"
正上方=上方+左对齐——
android:layout_above="@id/imageView"
android:layout_alignLeft="@id/imageView"
正左方=左边+顶端对齐——
(通过调节图片大小,设置正对齐)也可以加间距调整
android:layout_toLeftOf="@id/imageView"
android:layout_alignTop="@id/imageView"
正下方=下方+左对齐——
android:layout_below="@id/imageView"
android:layout_alignLeft="@id/imageView"
正右方=右方+顶端对齐——
android:layout_toRightOf="@id/imageView"
android:layout_alignTop="@id/imageView"