005帧布局管理器

1.      后面的组件会覆盖前面的组件,默认从左上角开始

2.      FrameLayou主要两个属性,foreground和foregroundGravity

foreground设置布局前景图像(始终位于最上层的图像)

foregroundGravity设置前景图像位置的(center之类的值,多个则用|隔开)

3.      为前景图像设置显示位置后(设置foregroundGravidy后),图像就会按照原来的大小显示,不然就是图像是整个页面那么大

代码


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:foreground="@mipmap/img1"
    android:foregroundGravity="right|bottom"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    
    <TextView
        android:layout_width="280dp"
        android:layout_height="280dp"
        android:layout_gravity="center"
        android:background="#ff0000ff"
        android:text="蓝色背景的textview"
        android:textColor="#ffffff"/>

    <TextView
        android:layout_width="230dp"
        android:layout_height="230dp"
        android:layout_gravity="center"
        android:background="#0077ff"
        android:text="天蓝色背景的textview"
        android:textColor="#ffffff"/>

    <TextView
        android:layout_width="180dp"
        android:layout_height="180dp"
        android:layout_gravity="center"
        android:background="#ff00b4ff"
        android:text="水蓝色背景的textview"
        android:textColor="#ffffff"/>


</FrameLayout>

猜你喜欢

转载自blog.csdn.net/qq_38309980/article/details/80885427