常见属性
android:foreground
:设置前景android:foregroundGravity
:设置前景位置
说明
FrameLayout
的其他属性与前面学的差不多,只不过需要特别注意上面两个即可
项目结构
主要代码
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:background="#ff0000"
android:layout_width="400dp"
android:layout_height="400dp" />
<FrameLayout
android:foreground="@drawable/test"
android:foregroundGravity="bottom|center"
android:background="#00ff00"
android:layout_width="300dp"
android:layout_height="300dp" />
<FrameLayout
android:background="#0000ff"
android:layout_width="200dp"
android:layout_height="200dp" />
</FrameLayout>
test.jpg