LinearLayout and FrameLayout

[align=center]LinearLayout and FrameLayout[/align]
[list]
[*]LinearLayout 单层线性布局,子控件不可覆盖,而以垂直或水平布局。
[/list]
[list]
[*]FrameLayout 单帧空间垂直布局,display a singer item,but you can populate it with many items, setting one to visible while the others are invisible.只有一个子控件可见,其它均被隐藏。每个添加的子控件都被放在布局的左上角,并覆盖前一子控件的上层。
[/list]

LinearLayout 做出如下效果:
[img]http://dl.iteye.com/upload/picture/pic/77263/0a2fdc2c-2293-31c2-b90e-3d8020e21f50.png[/img]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="160px"
android:background="@android:color/white"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>

<com.studio.android.Chessboard android:id="@+id/snake" android:layout_width="match_parent"
android:layout_height="match_parent" tileSize="24"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black"
>
</LinearLayout>
</LinearLayout>


分析:The first LinearLayout 垂直布局,所以TextView and Chessboard 垂直分布。第二个LinearLayout则位于其下。也就是两个LinearLayout不相互重叠,依次排列。

FrameLayout的布局:
[img]http://dl.iteye.com/upload/picture/pic/77269/92f7eb64-a76e-3927-bdd3-5cfd18e08d1d.png[/img]
[code]<?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"
android:background="@drawable/bg"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:text="@string/hello"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ff0000"
android:textSize="24sp"
/>
</RelativeLayout>
<Button
android:layout_width="50px"
android:layout_height="wrap_content"
android:text="确定"
/>
</FrameLayout>[/code]
分析:在整个的FrameLayout的布局中,上层子控件覆盖下层子控件,每个子控件都被放在左上角(0,0)位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值