它相对来说简单很多,它叫帧布局,但我更想叫它为层叠布局,用它做叠加效果
就一个属性: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>
效果图:

网友评论