您的位置:首页 > 其它

「喵神成长史」『布局篇』FrameLayout(帧布局)

2015-11-15 01:28 288 查看

帧布局基本介绍

帧布局在屏幕上直接开辟出一块空白区域,当往里面添加组件时,所有的组件都会在这片区域。帧布局在游戏中用的比较多,也是比较简单的一个布局。

重要的xml属性:

属性说明
foregound设置帧布局的前景图像
foregoundGravity设置帧布局前景图像的位置
代码:

<?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"
android:foreground="@drawable/e5"
android:foregroundGravity="bottom|left"
>
<TextView
android:layout_height="300dp"
android:layout_width="300dp"
android:background="#7162FF"/>
<TextView
android:layout_height="180dp"
android:layout_width="180dp"
android:background="#FF265B"/>
<TextView
android:layout_height="100dp"
android:layout_width="100dp"
android:background="#51FF5F"/>

</FrameLayout>


运行:

还是可以看出,后来的TextView会覆盖在以前TextView上,而右下角用了foregound属性的图片覆盖在三个TextView上

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: