Android五种布局管理器之『FrameLayout』
来源:互联网 发布:php企业门户网站模板 编辑:程序博客网 时间:2024/05/24 05:54
帧布局(FrameLayout)在屏幕上开辟了一块区域,在这块区域中可以添加多个子控件,但是所有的子控件都会被对齐到屏幕的左上角。帧布局的大小由其下属子控件中尺寸最大的那个子控件来控制。如果子控件的大小都一样,同一时刻只能看到最上面的子控件,其他的则被其遮挡(在进行选项卡设计时会用到帧布局)。
FrameLayout继承自ViewGroup类,除了继承自父类的属性和方法,FrameLayout类中也包含了自己特有的一些属性和方法,见下表:
属性名称对应方法描述android:foregroundsetForeground(Drawable)设置绘制在所有子控件之上的内容android:foregroundGravitysetForegroundGravity(int)设置绘制在所有子控件之上内容的gravity属性提示:在FrameLayout中,子控件是通过栈来绘制的,所以后添加的子控件会被绘制在上层。
下面就来看一个帧布局的例子效果图:
其中Main.xml代码如下:
view plain copy
- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout
- android:id="@+id/FrameLayout01"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#FFFFFF"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <TextView
- android:text="大字体"
- android:id="@+id/TextView01"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="60px"
- android:textColor="#00FF00"
- >
- </TextView>
- <TextView
- android:text="中字体"
- android:id="@+id/TextView02"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="40px"
- android:textColor="#FF0000"
- >
- </TextView>
- <TextView
- android:text="小字体"
- android:id="@+id/TextView03"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="20px"
- android:textColor="#0000FF"
- >
- </TextView>
- </FrameLayout>
Activity代码为:
view plain copy
- package com.sunchis;
- import android.app.Activity;
- import android.os.Bundle;
- public class Android extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main); //设置屏幕
- }
- }
- Android五种布局管理器之『FrameLayout』
- Android五种布局管理器之『FrameLayout』
- Android五种布局管理器之『FrameLayout』
- Android五种布局管理器之『RelativeLayout』
- Android五种布局管理器之『RelativeLayout』
- Android五种布局管理器之『LinearLayout』
- Android五种布局管理器之『AbsoluteLayout』
- Android五种布局管理器之『TableLayout』
- Android五种布局管理器之『LinearLayout』
- Android五种布局管理器之『RelativeLayout』
- Android五种布局管理器之『AbsoluteLayout』
- Android五种布局管理器之『TableLayout』
- Android框架布局管理器FrameLayout
- 一步一步学android之布局管理器——FrameLayout
- android五大布局之FrameLayout(框架布局)
- Android学习-五布局之帧布局(FrameLayout)
- android四种布局管理器 FrameLayout LinearLayout TableLayout RelativeLayout
- Android布局之FrameLayout
- java中二进制、八进制、十六进制转换为String
- 靠边伸缩菜单的做法(类似QQ,碰到就会伸出来)
- action返回值及结果类型介绍
- BI学习笔记之三 - 一个典型的BI系统介绍
- WCF 接口动态调用(动态创建实例接口)
- Android五种布局管理器之『FrameLayout』
- Cygwin 1.7版 中文问题的解决
- Android系统移植与调试之------->Android的编译系统简介
- 把阿拉伯数字转化成大写
- Lpad()函数与Rpad()函数的格式、用法
- Java web工程判断用户是否重复登录
- 线程与SMP
- Linux RPM包
- KMP匹配算法