第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的排列规则是:从左到右依次排列,如果右边不够放下,就换一行重复上面的方式排放,,,,, 常用的 ...
随机推荐
- Github 开源编辑器 ATOM 已开放下载
Update:2014-09-08 Atom 于5月6日正式开放下载(遗憾的是只有 MAC 版本),并且在 MIT 协义下开源,从界面可以看出,这款软件很像 Sublime Text,不过由于她的开源 ...
- 创建Chromium WebUI接口
转载自:http://www.chromium.org/developers/webui Chrome的WebUI是那种,在Chrome中输入 "chrome://xxxx"就能打 ...
- X Shell 4配色方案[Solarized Dark]
X Shell 4是个很好的Windows下登录Linux服务器的终端,比Putty好用 X Shell 4的下面这种方案,我个人很喜欢 用vim写shell脚本的效果: 按如下步骤配置: 1)把下面 ...
- OpenSSL之PKey的EVP封装
在Openssl中,非对称加密涉及到两个密钥.一个为公开的密钥(公钥),一个为非公开的密钥.而OpenSSL中非对称加密算法有RSA.DSA.ECC,他们的原理不同,因此其密钥结构不同.下面我们列出我 ...
- [Cocos2d-x v3.x]序列帧动画
简单介绍 Cocos2d-x中.动画的详细内容是依靠精灵显示出来的,为了显示动态图片,我们须要不停切换精灵显示的内容.通过把静态的精灵变为动画播放器从而实现动画效果. 动画由帧组成,每一帧都是一个 ...
- Linux以KB显示内存大小
Linux以KB显示内存大小 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ free -k total used free shared buffers ca ...
- cocos2d-x v3.2 FlappyBird 各个类对象详细代码分析(7)
今天我们介绍最后两个类 GameOverLayer类 GameLayer类 GameLayer类是整个游戏中最重要的类,由于是整个游戏的中央系统,控制着各个类(层)之间的交互,这个类中实现了猪脚小鸟和 ...
- C++指针数组和数组指针
指针相关问题 using namespace std; int main(){ //a) 一个整型数( An integer) int a; //b) 一个指向整型数的指针( A pointer to ...
- web笔记
application: 在tomcat启动过程,会将所有的应用加载进来,会为每一个应用创建一个application对象.这个对象是唯一.但是所有的web应用是互不影响的. like模糊查询 重定向 ...
- Jqgrid的用法总结与分页功能的拓展
这是本人写的第一个与技术相关的博客,但是非挑战技术的,而是对工作的总结,另外加一点点拓展. Jqgrid的功能十分强大,强大到可以做到与数据grid相关的任何功能,同时由于在用的过程中总是不能够一气呵 ...