FrameLayout之我见
来源:互联网 发布:广州有机云计算 编辑:程序博客网 时间:2024/06/05 09:30
在Android中有着几种不同的布局,例如:线性布局、帧布局、表格布局、绝对布局和相对布局。之前一直对帧布局不是很理解,今天仔细看了看,就记录如下:
首先是看了一下官方文档的说明,以下是我个人的翻译,呵呵,英语太差,感觉翻译的不好:
帧布局被设计用来再屏幕上留下一个区域显示单个元素。一般地,帧布局应该被用来显示单个子视图,因为当多个子视图互相不重叠时,要想再不同尺寸的屏幕上组织多个子视图是非常困难的。当然,你还是可以添加多个子元素,并且通过给每个子元素指定
android:layout_gravity这个属性来控制它们在帧布局中的位置!
帧布局的子元素都放在一个栈中,最近添加的哪一个就是栈顶元素。帧布局的尺寸决定于它所包含的最大的那个子元素的尺寸(包括填充的区域(padding)),而不管它是否可见(如果它的父组件允许).
通过上面的介绍我们基本可以理解:可以在帧布局里面放置多个组件,这些组件从屏幕的左上角,也即屏幕坐标的(0,0)处开始显示,并且后面的组件会覆盖前面的组件!
我们这里通过在一个FrameLayout中放置3个TextView来实现帧布局,3个TextView必须设置不同的尺寸,而且从下到上尺寸要依次减小,否则覆盖后只能看到最后的那个组件,为了使效果明显,我们还将他们设置为不同的颜色!
这里我们只需设置布局文件即可,具体代码如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@+id/FrameLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="200px" android:height="200px" android:background="#a00"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="150px" android:height="150px" android:background="#0a0"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100px" android:height="100px" android:background="#00a"/> </FrameLayout></LinearLayout>
- FrameLayout之我见
- Android UI 之FrameLayout(-)
- android Layout之FrameLayout
- Android布局之FrameLayout
- Android之FrameLayout布局
- A017-布局之FrameLayout
- Android-布局之FrameLayout
- android 开发布局之FrameLayout
- Android UI布局之FrameLayout
- andorid之帧布局FrameLayout
- android布局方式之FrameLayout
- Anroid布局文件之FrameLayout
- 布局之TableLayout和FrameLayout
- Android之FrameLayout的使用
- android之FrameLayout属性foreground
- Android之FrameLayout(帧布局)
- Android之FrameLayout(帧布局)
- FrameLayout
- Microsoft SQL Server 2008 install error
- protel99 封装定义
- 统计学 学习笔记 (七)—— 回到现实:得不到数据的整体怎么办?
- MVP这一年
- C/C++ 通用 Makefile
- FrameLayout之我见
- C# Winform 应用程序中,获取某网页的源文件
- Rational软件安装手册—DOORS
- Postfix的配置详解
- filter:alpha(opacity=100,style=1)
- Altium Designer 加LOGO方法
- 批处理作业调度-----回溯法
- C++ 类访问控制public/private/protected探讨
- postfix如何添加邮箱用户?