2.2.3帧布局

2017-10-26  本文已影响0人  EDU_MJ

帧布局的概念

帧布局(FrameLayout)为每个加入其中的控件创建一个空白区域(称为一帧,每个控件占据一帧)。
所有控件都默认显示在屏幕左上角,按照先后放入的顺序重叠摆放。帧布局的大小由内部最大控件的决定。

常用属性


属性 含义
android:foreground 设置帧布局容器的前景图像(始终处于所有子控件之上)
android:forgroundGravity 设置前景图像显示位置
android:background 设置背景

例如:设置帧布局的前景对象,加入两个按钮作为两个帧。

<?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="@mipmap/ic_launcher"
    android:foregroundGravity="center">
    <Button
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="#223456"/>
    <Button
        android:layout_width="200dp"
        android:layout_height="450dp"
        android:background="#990000"/>
</FrameLayout>
上一篇 下一篇

猜你喜欢

热点阅读