第24讲 UI_布局 之帧布局 表格布局 绝对布局

3.
FrameLayout(
帧布局)

帧布局是从屏幕的左上角(0,0)坐标开始布局,多个组件层叠排序,后一个组件总会将前一个组件所覆盖,除非最后一个组件是透明的。

<Button

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Button1"   />

<Button

android:layout_width="wrap_content"

android:layout_height="fill_parent"

android:text="Button2"   />

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button3"   />

此布局通常用于软件的初始化页面,启动页面等。

属性名称

对应方法

说明

android:foreground

setForeground(Drawable)

设置该帧布局容器的前景图像

android:foregroundGravity

setForegroundGravity(int)

设置前景图像显示的位置

4. TableLayout(表格布局)

TableLayout(表格布局),顾名思义就是像表格一样布局,以行、列的方式布局子组件。TableLayout使用TableRow对象来定义多行。每个TableRow就是一行

<TableRow>

<Button android:text="Button1"/>

<Button android:text="Button2"/>

<Button android:text="Button3"/>      </TableRow>

<TableRow>

<Button android:text="Button4"/>

<Button android:text="Button5"/>

<Button android:text="Button6"/>      </TableRow>

<TableRow>

<Button android:text="Button7"/>

<Button android:text="Button8"/>

<Button android:text="Button9"/>      </TableRow>

 TableLayout中也有几个常用属性:

(1) android:shrinkColumns属性:以0为序,当TableRow里面的控件布满布局时,指定列自动延伸以填充可用部分;当TableRow里面的控件还没有布满布局时,shrinkColumns不起作用。

(2) android:strechColumns:以第0行为序,指定列对空白部分进行填充

(3) android:collapseColumns:以0行为序,隐藏指定的列

(4) android:layout_column:以0行为序,设置组件显示指定列。

(5) android:layout_span:以第0行为序,设置组件显示占用的列数。

 //16个按钮

<Button  android:id="@+id/one"        android:text="1"/>

<Button          android:id="@+id/two"          android:text="2"/>

<Button          android:id="@+id/three"      android:text="3"/>

<Button          android:id="@+id/devide"     android:text="/"/>

<Button          android:id="@+id/four"          android:text="4"/>

<Button          android:id="@+id/five"          android:text="5"/>

<Button          android:id="@+id/six"             android:text="6"/>

<Button          android:id="@+id/multiply"   android:text="×"/>

<Button          android:id="@+id/seven"       android:text="7"/>

<Button          android:id="@+id/eight"        android:text="8"/>

<Button          android:id="@+id/nine"         android:text="9"/>

<Button          android:id="@+id/minus"        android:text="-"/>

<Button          android:id="@+id/zero"         android:layout_columnSpan="2"   android:layout_gravity="fill"android:text="0"/>

<Button          android:id="@+id/point"        android:text="."/>

<Button          android:id="@+id/plus"          android:layout_rowSpan="2"  android:layout_gravity="fill"android:text="+"/>

<Button          android:id="@+id/equal"       android:layout_columnSpan="3"  android:layout_gravity="fill" android:text="="/>

5. AbsoluteLayout(绝对布局)

AbsoluteLayout(绝对布局),组件的位置可以准确的指定其在屏幕的x/y坐标位置。虽然可以精确的去规定坐标,但是由于代码的书写过于刚硬,使得在不同的设备,不同分辨率的手机移动设备上不能很好的显示应有的效果,所以此布局不推荐使用。

<Button

android:layout_width="wrap_content"

android:layout_height="fill_parent"

android:text="Button1"

android:layout_x="100dp"  />

<Button

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Button2"

android:layout_y="100dp"   />

第24讲 UI_布局 之帧布局 表格布局 绝对布局的更多相关文章

  1. 第21/22讲 UI_布局 之 线性布局

    第21/22讲 UI_布局 之 线性布局 布局管理就是组件在activity中呈现方式,包括组件的大小,间距和对齐方式等. Android提供了两种布局的实现方式: 1.在xml配置文件中声明:这种方 ...

  2. 第23讲 UI_布局 之相对布局

    第23讲 UI_布局 之相对布局 .RelativeLayout(相对布局): RelativeLayout(相对布局)是指组件的位置总是相对兄弟组件.父容器来决定的(相对位置),如某个组件的左边右边 ...

  3. android的布局-----FrameLayout(帧布局)

    (-)帧布局简介 帧布局容器为每个加入的其中的组件创建一个空白的区域称为一帧每个子组件占据一帧,这些帧都会根据gravity的属性执行自动对齐 (二)属性 foreground:这是帧布局的前景图像 ...

  4. Android线性布局和帧布局

    第二次,本牛崽十分从容,今天咱们来讲讲Android Q之布局,我遇到的问题与自己学到的,大牛不要嘲笑哈,有错误可以指出来,本牛崽看到就改了. 今天我的学长跟我们开始了布局,布局看资料说好像有5种,又 ...

  5. Android开发5:布局管理器2(表格布局TableLayout)

    版本:Android4.3 API18  学习整理:liuxinming 概念      TableLayout继承了LinearLayout,因此它的本质依然是线性布局管理器.      表格布局采 ...

  6. 【Flutter学习】页面布局之列表和表格处理

    一,概述 Flutter中拥有30多种预定义的布局widget,常用的有Container.Padding.Center.Flex.Row.Colum.ListView.GridView.按照< ...

  7. CSS布局:Float布局过程与老生常谈的三栏布局

    原文见博客主站,欢迎大家去评论. 使用CSS布局网页,那是前端的基本功了,什么两栏布局,三栏布局,那也是前端面试的基本题了.一般来说,可以使用CSSposition属性进行布局,或者使用CSSfloa ...

  8. 转:CSS布局:Float布局过程与老生常谈的三栏布局

    使用CSS布局网页,那是前端的基本功了,什么两栏布局,三栏布局,那也是前端面试的基本题了.一般来说,可以使用CSSposition属性进行布局,或者使用CSSfloat属性布局.前者适合布局首页,因为 ...

  9. iOS:UICollectionView流式布局及其在该布局上的扩展的线式布局

    UICollectionViewFlowLayout是苹果公司做好的一种单元格布局方式,它约束item的排列规则是:从左到右依次排列,如果右边不够放下,就换一行重复上面的方式排放,,,,,   常用的 ...

随机推荐

  1. 【自由谈】城域网IPv6过渡技术——4v6场景技术总结(1)

    为什么会存在4v6应用场景?主要是从“云-管-端”的IPv6状态决定的,“云”侧IPv4类业务丰富,IPv6驱动力小,所以“云”在较长一段时间内还是以IPv4类业务为主.“管”侧的IPv6化程度高,设 ...

  2. 读《MacTalk&#183;人生元编程》及Mac经常使用软件

    引子 池建强的Blog:http://www.cnblogs.com/chijianqiang/ 用了1年多的黑苹果,是用Windows的思维用UI.用Linux的思维用Shell,折腾的是联想E49 ...

  3. 秀才每天一篇之—SEO是什么?

    [导读]SEO是什么?秀才搁笔七天以来.遇到非常多事情.站点被K ,排名掉了. 却找不出原因,開始迷茫了.以至于没有心情来照应这个博客,不好意思了,各位.在这七天以来.秀才一直在思考,SEO究竟应该怎 ...

  4. debian linux 中如何查看软件包是否已经安装和如何安装、卸载软件

    练习 1 方案:确定软件包是否安装 如果您不确定某个软件包是否已经安装,可以使用 dpkg 的 -l (L的小写) 选项: $ dpkg -l zsh No packages found matchi ...

  5. Linux内核ROP学习

    0x00 前言 1.SMEP(Supervisor Mode Execution Protection):一种减缓内核利用的cpu策略,禁止内核态到用户态内存页的代码执行(32位的addresses ...

  6. Sass函数--数字函数

    数字函数简介 Sass 中的数字函数提要针对数字方面提供一系列的函数功能: percentage($value):将一个不带单位的数转换成百分比值: round($value):将数值四舍五入,转换成 ...

  7. visual studio插件 visual assistx

    http://www.wholetomato.com/downloads/CheckForUpdate.asp?v=1925&e=&b=n&r=y&i=10&v ...

  8. poj3468 线段树+lazy标记

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 92921   ...

  9. LAMP 搭建wordpress部署教程贴.

    LAMP 搭建wordpress部署教程贴.这是一篇主要将LAMP,并且通过wordpress来进行验证,演示.如何去部署PHP CMS很多新手看到LAMP就很很头大,觉得很难搞,编译安装,搞了好几天 ...

  10. google 地图,多个标记 js库

    360 云盘:http://yunpan.cn/cVgU3X7JFxAGY (提取码:1f07) 百度云盘:链接: http://pan.baidu.com/s/1c0fbCWw 密码: w1pm 参 ...