A017-布局之FrameLayout

FrameLayout

帧布局,是所有布局容器中最简单的一种,控件定义在FrameLayout中默认放置在左上角,定义在后面的控件会层叠在前面定义的控件之上,所以才会被称为帧布局。

应用

据我个人的开发经验,FramLayout主要用于比较简单的布局,最常见的一个应用场景就是”功能引导页”,就是在布局最外层遮罩一层半透明的视图,类似以下这种:
Android遮罩

举例

<?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">


    <Button
        android:id="@+id/button7"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="第一个Button" />

    <Button
        android:id="@+id/button8"
        android:layout_width="90dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="10dp"
        android:text="第二个Button"
        android:background="#ffff00"/>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#38000000"
        android:gravity="center"
        >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/arrow"
            android:layout_gravity="center"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="最外面一层"
            />
    </LinearLayout>

</FrameLayout>

效果图:
遮罩效果

上面的效果是第二个Button覆盖在第一个Button的上面,除了被覆盖的位置,第一个Button的其他位置是可以点击的,最外层用半透明效果覆盖全部布局,这里只是简单示例FrameLayout的应用,实际开发中,用素材来摆放位置来达到引导用户的效果。

转载请注明:IT_xiao小巫 http://blog.csdn.net/wwj_748

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小巫技术博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值