A017-布局之FrameLayout

作者: IT_xiao小巫 | 来源:发表于2015-10-04 21:17 被阅读1314次

FrameLayout

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

应用

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


Android遮罩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

相关文章

  • A017-布局之FrameLayout

    FrameLayout 帧布局,是所有布局容器中最简单的一种,控件定义在FrameLayout中默认放置在左上角,...

  • CardView基础使用

    引用: 布局:cardview继承FrameLayout,所以布局跟FrameLayout一样 属性: (1):设...

  • Android 布局之FrameLayout

    1 .FrameLayout简介 设计FrameLayout是为了显示单一项widget。通常,不建议使用Fram...

  • Android学习笔记——常用布局

    一、布局 FrameLayout(框架布局) LinearLayout(线性布局) AbsoluteLayout(...

  • Android Fragment的切换

    在主布局中有FrameLayout,如何在代码中对FrameLayout进行切换不同的Fragment呢? 布局文...

  • android基础

    布局基本布局 FrameLayout线性布局 LinearLayout相对布局 RelativeLayout绝对布...

  • Android merge标签

    当界面的跟布局为FrameLayout时,使用merge代替FrameLayout可以减少布局的层级,因为Cont...

  • Android学习笔记

    TableLayout 表格布局 AbsoulteLayout 绝对布局 FrameLayout 帧布局 Rela...

  • 帧布局(FrameLayout)

    今天来说下 Android中几大布局中的FrameLayout, FrameLayout是几个布局中最简单的一个布...

  • 布局ViewGroup原理解析(四):FrameLayout

    今天来说下 Android中几大布局中的FrameLayout, FrameLayout是几个布局中最简单的一个布...

网友评论

    本文标题:A017-布局之FrameLayout

    本文链接:https://www.haomeiwen.com/subject/lrvgcttx.html