Android五种布局管理器之『FrameLayout』
来源:互联网 发布:河南省软件服务业协会 编辑:程序博客网 时间:2024/05/13 23:54
转载http://www.sunchis.com/html/android/devolop/2011/0424/318.html
帧布局(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的安装与配置
- hdu 1709 (母函数,有些特殊)
- Java RandomAccessFile的使用
- 关于spring与hibernate整合后的事务
- 创业12年 最野蛮的屌丝创业者
- Android五种布局管理器之『FrameLayout』
- linux unzip程序简介
- Android五种布局管理器之『AbsoluteLayout』
- 【程序猿笔试面试解题指南】求字符串中不含重复字符的最长子串
- 2013-04-06 C++再续
- Android五种布局管理器之『TableLayout』
- 工资类
- Eclipse用法和技巧一:还原视图和编辑器
- hdu 1708 (字符串,Fibonacci )