码迷,mamicode.com
首页 > 其他好文 > 详细

A017-布局之FrameLayout

时间:2015-10-04 19:42:17      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:布局   android   

FrameLayout

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

应用

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

举例

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

标签:布局   android   

原文地址:http://blog.csdn.net/wwj_748/article/details/48897247

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!