运行结果
在布局管理器上所设置的属性
android:foreground
前景图像
android:foregroundGravity
前景图像的位置
android:foreground="@mipmap/aa"
android:foregroundGravity="center|right"
重叠正方形实例
<?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"
android:foreground="@mipmap/aa"
android:foregroundGravity="center|right"
tools:context=".MainActivity">
<TextView
android:layout_width="300dp"
android:layout_height="300dp"
android:text="Hello World!Hello World!"
android:textColor="#ffffff"
android:background="#00ff00"
android:layout_gravity="center"
/>
<TextView
android:layout_width="250dp"
android:layout_height="250dp"
android:text="Hello World!"
android:textColor="#ffffff"
android:background="#0077ff"
android:layout_gravity="center"
/>
<TextView
android:layout_width="150dp"
android:layout_height="150dp"
android:text="Hello!"
android:textColor="#ffffff"
android:background="#ff00ff"
android:layout_gravity="center"
/>
</FrameLayout>