它相對來說簡單很多,它叫幀佈局,但我更想叫它爲層疊佈局,用它做疊加效果
就一個屬性:android:layout_gravity
示例代碼:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".groupview.FrameLayoutActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="@mipmap/img_apply_talent_bg"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg"
android:layout_gravity="center_horizontal"
android:textColor="@color/white"
android:text="中間"/>
</FrameLayout>
效果圖: