Android RelativeLayout 相对布局
示例
RelativeLayout是一个ViewGroup以相对位置显示子视图的。默认情况下,所有子视图都绘制在布局的左上角,因此您必须使用中提供的各种布局属性来定义每个视图的位置RelativeLayout.LayoutParams。每个layout属性的值可以是一个布尔值(启用相对于父RelativeLayout的布局位置),或者是一个ID,该ID引用该布局中应针对其放置视图的另一个视图。
例:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@mipmap/ic_launcher" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"
android:hint="@string/hint" />
</RelativeLayout>这是一个屏幕截图,看起来像这样: