3、TableLayout(表格布局)

像表格一样布局,通常情况下,TableLayout有多个TableRow组成,每个TableRow就是一行。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="2">
<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]shrinkColumns属性:以0行为序,当TableRow里面的控件布满布局时,指定列自动延伸以填充可用部分;当TableRow里面的控件还没有布满布局时,shrinkColumns不起作用。(android:shrinkColumns="2",第3列布满时填充)

[2]strechColumns属性:以第0行为序,指定列对空白部分进行填充。(android:strechColumns="2",第3列填充)

[3]collapseColumns属性:以0行为序,隐藏指定的列.。(android:strechColumns="2",隐藏第3列)

[4]layout_column属性:以0行为序,设置组件显示指定列。(android:layout_column="2",显示在第三列)

[5]layout_span属性:以第0行为序,设置组件显示占用的列数。(android:layout_span="3",占用3列)

4、AbsoluteLayout(绝对布局)

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

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<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"
/> </AbsoluteLayout>

5、FrameLayout(单帧布局)

据说是五种布局中最简单的一种,因为单帧布局在新定义组件的时候都会将组件放置屏幕的左上角,即使在此布局中定义多个组件,后一个组件总会将前一个组件所覆盖,除非最后一个组件是透明的。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<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"
/> </FrameLayout>

Android 之布局(二)的更多相关文章

  1. Android开发--布局二

    1.Andrid:控件布局(表格布局)TableLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 ...

  2. Android学习系列(二)布局管理器之线性布局的3种实现方式

    转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39643669 LinearLayout是Android控件中的线性布局控件,它包括的子控件 ...

  3. [转]浅谈Android五大布局(二)——RelativeLayout和TableLayout

    在浅谈Android五大布局(一)中已经描述了LinearLayout(线性布局).FrameLayout(单帧布局)和AbsoulteLayout(绝对布局)三种布局结构,剩下的两种布局Relati ...

  4. Android仿微信二维码扫描

    转载:http://blog.csdn.net/xiaanming/article/details/10163203 了解二维码这个东西还是从微信中,当时微信推出二维码扫描功能,自己感觉挺新颖的,从一 ...

  5. Xamarin.Android之布局文件智能提示问题

    一.前言 看到有人问关于xamarin.android的布局没智能提示问题(VS 2015),当然,写布局这东西没提示这是一件相对痛苦的事 ,所以这里就提供一个解决的方案! 二.解决方案 想要智能提示 ...

  6. Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误

    嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...

  7. Android基本布局

    android基本布局有三种:LinearLayout,RelativeLayout,FrameLayout. 一.LinearLayout 1,这是一种垂直布局(或者水平布局),可以通过下面这一句来 ...

  8. Android 优化布局层次结构

    前面介绍过使用HierarchyViewer和Android lint来优化我们的程序,这一篇算是总结性的,借助一个小例子来说用怎么优化应用布局.这个例子是android官网给出的,作者也当一把翻译. ...

  9. android的布局管理器

    理论上通过setContentView(view)能够把一个view设置到activity中,但当你有很多个view控件的时候,就需要用android的布局管理器来管理view控件了. android ...

  10. Android用户界面布局(layouts)

    Android用户界面布局(layouts) 备注:view理解为视图 一个布局定义了用户界面的可视结构,比如activity的UI或是APP widget的UI,我们可以用下面两种方式来声明布局: ...

随机推荐

  1. 【洛谷】4917:天守阁的地板【欧拉函数的应用】【lcm与gcd】【同除根号优化】

    P4917 天守阁的地板 题目背景 在下克上异变中,博丽灵梦为了找到异变的源头,一路打到了天守阁 异变主谋鬼人正邪为了迎击,将天守阁反复颠倒过来,而年久失修的天守阁也因此掉下了很多块地板 异变结束后, ...

  2. bzoj 1027 floyd求有向图最小环

    结合得好巧妙.... 化简后的问题是: 给你两个点集A,B,求B的一个子集BB,使得BB的凸包包含A的凸包,求BB的最小大小. 先特判答案为1,2的情况,答案为3的情况,我们先构造一个有向图: 对于B ...

  3. BZOJ 4521 CQOI 2016 手机号码 数位DP

    4521: [Cqoi2016]手机号码 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 539  Solved: 325[Submit][Status ...

  4. PYQT控件使用

    QtGui.QComboBox .addItem(string)#添加字符串项到Item.addItems(list)#添加列表或元组元素到Item.clear()#清除所有Item.clearEdi ...

  5. php的哈希函数

    哈希函数: echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n"; 验证函数: boolean  ...

  6. SQLyog客户端无法连接MySQL服务器

    环境:centos下使用yum 命令安装了mysql服务 1.进入linux 通过命令service mysqld start启动mysql的服务 2.使用sqlyog 连接mysql发现连接不上,如 ...

  7. 29防止程序集被篡改仿冒,全局程序集缓存GAC

      为什么需要强名称程序集和数字签名 有一个类库项目ClassLib,对应的程序集是ClassLib.dll.当前控制台项目引用ClassLib.dll程序集的方式有2种: 1.通过添加现有项目 文件 ...

  8. MVC日期格式化,后台使用Newtonsoft.Json序列化日期,前端使用”f”格式化日期

    MVC控制器中,经常使用Newtonsoft.Json把对象序列化成json字符串传递到前端视图.当对象中有DateTime类型的属性时,前后台如何处理才能把DateTime类型转换成想要的格式呢? ...

  9. Spring MVC的异步模式DefferedResult

    原文:http://www.importnew.com/21051.html 什么是异步模式 要知道什么是异步模式,就先要知道什么是同步模式,先看最典型的同步模式: (图1) 浏览器发起请求,Web服 ...

  10. CMMI管理体系

    帮助企业对软件工程过程进行管理和改进,增强开发与改进能力,从而按时,不超过预算地开发软件. CMMI为改进一个组织的各种过程提供了一个单一的集成化框架,新的集成模块框架消除了各个模型的不一致性,减少了 ...