帧布局相对来说比较简单,在开发中很少使用到,最前面的两种布局(线性布局、相对布局是比较常用的)。

在帧布局中我们只需要记住两点就ok:
1、不设定位置默认从(0,0)开始,也就是左上角开始。
2、顺序执行的,最后执行的在最顶端显示。(每次显示一个布局,最后面写的一定在最后显示,覆盖以前的所有层)
<?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" >
<View
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#F00"/>
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#0F0"/>
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#00F"/>
</FrameLayout>
显示结果为:

#F00红色在最下面,#0F0绿色在中间,#00F蓝色在最顶端。
帧布局解析
本文解析了帧布局在Android开发中的应用,介绍了其从左上角(0,0)开始绘制及后绘制元素覆盖前者的特性,并通过示例展示了不同颜色视图的层级关系。
334

被折叠的 条评论
为什么被折叠?



