第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的排列规则是:从左到右依次排列,如果右边不够放下,就换一行重复上面的方式排放,,,,, 常用的 ...
随机推荐
- Git使用之基于SSH的Gitserver的client配置(下篇)
1. 软件安装 Git-1.9.2-preview20140411 TortoiseGit-1.8.8.0-64bit.msi 1.1 安装msysgit 很easy,基本就是一路下一步,有几个地方 ...
- android4.4 settings 中控制卡1 卡2都振动
在package/app/Settings/src/com/android/settings/SoundSettings.java
- oracle group by rollup,decode,grouping,nvl,nvl2,nullif,grouping_id,group_id,grouping sets,RATIO_TO
干oracle 047文章12当问题,经验group by 声明.因此邂逅group by rollup,decode,grouping,nvl,nvl2,nullif,RATIO_TO_REPOR ...
- linux程序自启动和新建linux服务的方法
1 linux创建自启动程序 自启动的两种方法,都经过自己测试.1.1 自启动程序方法1: 在etc/rc.local在里面加入/home/robin/code/autoruntest & ...
- Eclipse的Tomcat热部署,免重启的方法
背景与目标: 最好使用MyEclipse部署Web应用,在开发调试时,非常方式.资源文件修改可以自动的同步.修改Java文件,除非改变类的结构定义,也可以实现热部署的效果. 后来使用Eclipse J ...
- OD: Memory Attach Technology - Off by One, Virtual Function in C++ & Heap Spray
Off by One 根据 Halvar Flake 在“Third Generation Exploitation”中的描述,漏洞利用技术依攻击难度从小到大分为三类: . 基础的栈溢出利用,可以利用 ...
- No suitable authentication method found to complete authentication (publickey,keyboard-interactive).
string command = Command.Text; StringBuilder result = new StringBuilder(); try { var connectionInfo ...
- ---添加一条记录返回一条记录的ID
INSERT INTO Web_AD(PID,ADType,ADTitle,ADTitle1,ADTitle2,ADTarget,LinkURL,DispalyWords,ADCode,UploadI ...
- ref和out与SQL中的output
什么时候会需要使用ref和out 有时,我们会需要获取某个值在方法中的运行状态,根据定义的方法,我们仅仅能够获得一个返回值,但是,有时我们也许想获取多个值,通过返回值就不能返回这样的信息,我们可以通过 ...
- 安卓java设置字体颜色
textView03.setTextColor(this.getResources().getColor(R.color.botomfontColorUnSel));