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. bzoj 2150 最小路径覆盖

    最小路径覆盖问题是:给定一个DAG,该DAG的一个路径覆盖是一个路径的集合,使得每个点属于且仅属于其中一条路径,问题就是求一个大小最小的路径集合. 做法是将每个点A拆成两个点A1,A2,如果A-> ...

  2. OpenGL和GLSL版本更迭

    前言 最近才发现,自己写的glsl和教程的glsl版本对不上,一直以为是xcode不允许使用太高版本,只能使用OpenGL 2.0的版本,却不知使用glfw可以使用到最新的OpenGL版本.

  3. python开发_imghdr_图像格式支持

    在python中,imghdr模块对图像格式提供了支持 该模块主要是处理识别图像的格式 imghdr模块提供的函数如下: imghdr.what(filename, h=None) Tests the ...

  4. Codeforces Round #287 (Div. 2) B. Amr and Pins 水题

    B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  5. nginx 注册为linux系统服务

    #! /bin/sh # chkconfig: - 85 15 # description: nginx is a World Wide Web server. It is used to serve ...

  6. GIT 详解2

    https://segmentfault.com/a/1190000000738398 http://www.cnblogs.com/cposture/p/4903767.html https://g ...

  7. mysql 审计插件编写

    http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1864367&page=1#pid13527550 http://blog ...

  8. 使用Bootstrap 3开发响应式网站实践03,轮播下方的内容排版

    通常把一些重要信息.需要重点标注的信息放在轮播的下方显示,这部分区域用到了大字体的标题.副标题以及段落文字等. <div class="row" id="bigCa ...

  9. leetCode解题报告5道题(九)

    题目一:Combinations Given two integers n and k, return all possible combinations of k numbers out of 1 ...

  10. Caused by: org.xml.sax.SAXParseException: The reference to entity "characterEncoding" must end with the ';' delimiter.

    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Sourc ...