A017-布局之FrameLayout

FrameLayout

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

应用

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

举例

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

效果图:
A017-布局之FrameLayout_第2张图片

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

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

你可能感兴趣的:(android,布局)