Android帧布局FrameLayout

这种布局方式在七大大布局中最为简单,这个布局直接在屏幕上开辟出一块空白的区域,当我们往里面添加控件的时候,会默认把他们放到这块区域的左上角,而这种布局方式却没有任何的定位方式,所以它应用的场景并不多

<?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"
    android:foreground="@drawable/ic_launcher_foreground"
    android:foregroundGravity="right|bottom">

    <ImageView
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="#00ff00"/>

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ff0000"/>

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#0000ff"/>
    </FrameLayout>

效果图

猜你喜欢

转载自blog.csdn.net/I_am_a_loser/article/details/120151717