Android Layout之一:FrameLayout

来源:互联网 发布:linux查看检测网络命令 编辑:程序博客网 时间:2024/04/26 03:39

[转自 http://hi.baidu.com/hemisp/item/b5d2950ed87646f0a11034cc]


Android Layout有五大布局对象,分别是FrameLayout(帧布局),LinearLayout (线性布局),AbsoluteLayout(绝对布局),RelativeLayout(相对布局),TableLayout(表格布局). 

FrameLayout:该布局container可以用来占有屏幕的某块区域来显示单一的对象,可以包含有多个widgets或者是container,但是所有被包含的widgets或者是container必须被固定到屏幕的左上角,并且一层覆盖一层,不能通过为一个widgets或者是container指定一个位置。Container所包含的widgets或者是container的队列是采用的堆栈的结构,最后加进来的widgets或者是container显示在最上面。所以后一个widgets或者是container将会直接覆盖在前一个widgets或者是container之上,把它们部份或全部挡住(除非后一个widgets或者是container是透明的,必须得到FrameLayout Container的允许)。

其中Main.xml 代码如下:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    >

<TextView 

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="@string/hello"

    />

    <TextView

        android:textColor = "#0000FF"

        android:layout_width = "wrap_content"

        android:layout_height = "wrap_content"

        android:text = "@string/hello2"

       />

</FrameLayout>

Strings.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>

<resources>

    <string name="hello">Hello World, LayoutTestActivity!</string>

    <string name="app_name">LayoutTest</string>

    <string name="hello2">Hello World, I can not be LOST!</string>

</resources>

如下图,其中TextView Hello2是最后FrameLayout最后加入的,所以该TextView应该是覆盖整个屏幕的,TextView hello1被其覆盖:

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 2岁宝宝说话口吃怎么办 两岁宝宝突然口吃怎么办 两岁半的宝宝还不会说话怎么办 2岁宝宝自闭症怎么办呀 新生儿又吐又拉怎么办 一岁多宝宝受凉呕吐拉稀怎么办 7个月的宝宝腹泻怎么办 两岁宝宝拉稀水怎么办 2岁宝宝发烧呕吐怎么办 1岁宝宝着凉呕吐怎么办 2岁着凉了呕吐怎么办 2岁宝宝着凉呕吐怎么办 两岁宝宝偏矮怎么办 2岁宝贝吐没精神怎么办 11个月的宝宝吐怎么办 二岁的宝宝吐了怎么办 十个月小孩吐了怎么办 10个月宝宝呕吐怎么办 小孩又拉又吐的怎么办 小孩子不吃饭呕吐拉肚子怎么办 小孩发烧后又吐怎么办 11个月宝宝吐了怎么办 11个月宝宝拉肚子怎么办 2岁宝宝反复呕吐怎么办 1岁半幼儿拉肚子怎么办 宝宝打嗝呕吐胃难受怎么办 3岁宝宝发烧还吐怎么办 孩子喝水都吐怎么办啊 宝宝吃多了呕吐怎么办 3岁宝宝吐怎么办才好 儿童受凉肚子疼发热呕吐怎么办 两岁宝宝半夜呕吐怎么办 两岁宝宝吐了怎么办 2岁宝宝发烧吐怎么办 2岁多宝宝呕吐是怎么办 2周岁宝宝中暑了怎么办 2岁半宝宝着凉呕吐怎么办 3岁宝宝吐了几次怎么办 一岁宝宝恶心吐怎么办 9个月宝宝一直吐怎么办 晚上冻着了呕吐怎么办