前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >A017-布局之FrameLayout

A017-布局之FrameLayout

作者头像
巫山老妖
发布2018-07-23 10:09:55
4490
发布2018-07-23 10:09:55
举报
文章被收录于专栏:小巫技术博客

FrameLayout

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

应用

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

举例

代码语言:javascript
复制
<?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

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2015-10-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小巫技术博客 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • FrameLayout
    • 应用
      • 举例
      相关产品与服务
      容器服务
      腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档