一、帧布局的常用属性
    1.android:foreground 设置前景
    2.android:foregroundGravity 设置前景位置
    二、帧布局的实现
    注:帧布局是后者在前者的叠加下形成的,帧布局一般运用在渐变背景、片段页面。
    1.布局framelayout.xml文件

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3. xmlns:app="http://schemas.android.com/apk/res-auto"
    4. xmlns:tools="http://schemas.android.com/tools"
    5. android:layout_width="match_parent"
    6. android:layout_height="match_parent"
    7. >
    8. <FrameLayout
    9. android:layout_width="400dp"
    10. android:layout_height="400dp"
    11. android:background="#ff0000"
    12. />
    13. <FrameLayout
    14. android:layout_width="300dp"
    15. android:layout_height="300dp"
    16. android:background="#ffff00"
    17. android:foreground="@drawable/ic_launcher_background"
    18. android:foregroundGravity="right"
    19. />
    20. <FrameLayout
    21. android:layout_width="200dp"
    22. android:layout_height="200dp"
    23. android:background="#ff00ff"
    24. />
    25. </FrameLayout>

    2.效果图:
    image.png