框架布局FrameLayout

框架布局

框架布局是最简单的布局方式,所有添加到这个布局中的视图都是以层叠的方式显示。第一个添加到框架布局中的视图显示在最底层,最后一个呗放在最顶层,上一层的视图会覆盖下一层的视图,因此框架布局类似堆栈布局。

属性值描述
top将试图放到屏幕的顶端
Bottom将视图放到屏幕的底端
Left将视图放在屏幕的左侧
Right将视图放在屏幕的右侧
Center_vertical将视图按照垂直方向居中显示
horizontal_vertical将视图按照水平方向居中显示

例如:图片的层叠放置

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.FrameLayout.FrameLayoutActivity">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/frame_background"
        android:scaleType="fitCenter"
        android:layout_gravity="center"
        />
    <ImageView
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:background="@drawable/frame_person_bg"
        android:layout_marginTop="100dp"/>

</FrameLayout>

运行效果图
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值