第24讲 UI_布局 之帧布局 表格布局 绝对布局
第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_布局 之帧布局 表格布局 绝对布局的更多相关文章
- 第21/22讲 UI_布局 之 线性布局
第21/22讲 UI_布局 之 线性布局 布局管理就是组件在activity中呈现方式,包括组件的大小,间距和对齐方式等. Android提供了两种布局的实现方式: 1.在xml配置文件中声明:这种方 ...
- 第23讲 UI_布局 之相对布局
第23讲 UI_布局 之相对布局 .RelativeLayout(相对布局): RelativeLayout(相对布局)是指组件的位置总是相对兄弟组件.父容器来决定的(相对位置),如某个组件的左边右边 ...
- android的布局-----FrameLayout(帧布局)
(-)帧布局简介 帧布局容器为每个加入的其中的组件创建一个空白的区域称为一帧每个子组件占据一帧,这些帧都会根据gravity的属性执行自动对齐 (二)属性 foreground:这是帧布局的前景图像 ...
- Android线性布局和帧布局
第二次,本牛崽十分从容,今天咱们来讲讲Android Q之布局,我遇到的问题与自己学到的,大牛不要嘲笑哈,有错误可以指出来,本牛崽看到就改了. 今天我的学长跟我们开始了布局,布局看资料说好像有5种,又 ...
- Android开发5:布局管理器2(表格布局TableLayout)
版本:Android4.3 API18 学习整理:liuxinming 概念 TableLayout继承了LinearLayout,因此它的本质依然是线性布局管理器. 表格布局采 ...
- 【Flutter学习】页面布局之列表和表格处理
一,概述 Flutter中拥有30多种预定义的布局widget,常用的有Container.Padding.Center.Flex.Row.Colum.ListView.GridView.按照< ...
- CSS布局:Float布局过程与老生常谈的三栏布局
原文见博客主站,欢迎大家去评论. 使用CSS布局网页,那是前端的基本功了,什么两栏布局,三栏布局,那也是前端面试的基本题了.一般来说,可以使用CSSposition属性进行布局,或者使用CSSfloa ...
- 转:CSS布局:Float布局过程与老生常谈的三栏布局
使用CSS布局网页,那是前端的基本功了,什么两栏布局,三栏布局,那也是前端面试的基本题了.一般来说,可以使用CSSposition属性进行布局,或者使用CSSfloat属性布局.前者适合布局首页,因为 ...
- iOS:UICollectionView流式布局及其在该布局上的扩展的线式布局
UICollectionViewFlowLayout是苹果公司做好的一种单元格布局方式,它约束item的排列规则是:从左到右依次排列,如果右边不够放下,就换一行重复上面的方式排放,,,,, 常用的 ...
随机推荐
- oracle中 connect by prior 递归算法
Oracle中start with...connect by prior子句用法 connect by 是结构化查询中用到的,其基本语法是: select ... from tablename sta ...
- Label 添加表情图片
// 添加表情 NSTextAttachment *attch = [[NSTextAttachment alloc] init]; // 表情图片 attch.image = [UIImage im ...
- [Falcor] Building Paths Programmatically
model.setValue('genreList[0].titles[0].rating', 5) .then(function (value) { model.get('genreList[0.. ...
- (第三章)Java内存模型(下)
一.happens-before happens-before是JMM最核心的概念.对于Java程序员来说,理解happens-before是理解JMM的关键. 1.1 JMM的设计 从JMM设计者的 ...
- jquery 中ajax的参数
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- C#生成Code39(extend)条形码【非条形码字体】
Code39是条形码的一种.由于编制简单.能够对任意长度的数据进行编码.支持设备广泛等特性而被广泛采用. 能够对任意长度的数据进行编码.其局限在于印刷品的长度和条码阅读器的识别范围. 支持设备广泛.目 ...
- Sql Server添加用户
1.sa用户登陆之后,在安全性中新建登录名 2.添加登录名,下面的默认数据库选择该用户可访问的默认数据库 3.服务器角色中选择public 4.用户映射中选择该用户可访问的数据库,数据库角色一般选择p ...
- jq不识别拼接的对象id的解决方案
今天在做项目时,遇到了这么个问题. 先声明一下,我的id都是动态变换的.从1-10呢. <div id="a1"></div> <div id=&qu ...
- (一)Knockout - 入门
knockout 简介 knockoutjs的实现依照[MVVM模式],Model-View-ViewModel. Model,用来聚合server端数据 ViewModel,描述的数据以及操作,是行 ...
- hdu5362 Just A String(dp)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Just A String Time Limit: 2000/1000 MS (J ...