Android成长日记-五大布局

1. 五布局之线性布局LinearLayout

特点:它包含的子控件将以横向或竖向的方式排列

clip_image002

ps:android:gravity=”center|bottom”(gravity允许多级联用)

Tip:注意以下例子:

1 <Button
2 Android:layout_weight=”23 Android:layout_height=”wrap_parent”
4 Android:layout_width=”match_parent”/>
5 <Button
6 Android:layout_weight=”17 Android:layout_height=”wrap_parent”
8 Android:layout_width=” match _parent”/> 

=====================================================

 1 <Button
 2 
 3 Android:layout_weight=”2 4 
 5 Android:layout_height=”match_parent”
 6 
 7 Android:layout_width=”match_parent”/>
 8 
 9 <Button
10 
11 Android:layout_weight=”112 
13 Android:layout_height=”match_parent”
14 
15 Android:layout_width=”match_parent”/>

========================================================

2. 五布局之相对布局RelativeLayout

特点:它包含的子控件将以控件之间的相对位置或者子类控件相对父类容器的位置的方式排列

clip_image004

clip_image006

Ps:

clip_image008

========================================================

3.五布局之帧布局FrameLayout

特点:在这个布局中,所有的子元素都不能被制定放置的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。

clip_image010

Eg:通过FrameLayout设置类似进度条的效果

clip_image011

===============================================

4.五布局之绝对布局AbsoluteLayout

特点:又名坐标布局,可以直接指定子元素的绝对位置(XY)

缺点:由于手机屏幕尺寸差别较大,使用绝对定位的适应性会比较差,在屏幕的适配上有缺陷

clip_image013

5.五布局之表格布局TableLayout

特点:TableLayout表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View对象

clip_image015

------------------------------------------------------------

clip_image017

----------------------------------------------------------

collapseColumns是设置隐藏,shrinkColumns是设置收缩,stretchColumns是设置填充空白。TableLaout列是从0开始计数


[s1]这样的话上边的button占空间的2/3,下面的button1/3

[s2]这样的话上边的button1/3,下面的button2/3

posted @ 2015-02-26 19:41  monsterLin  阅读(267)  评论(0编辑  收藏  举报
小弟博客地址迁移,欢迎戳这里查看新博客~