- 浏览: 150100 次
- 性别:
- 来自: 五指山
文章分类
最新评论
-
dengdonglin888:
qq_30221445 写道你好 请问这种数据能解吗 < ...
Simple XML -
qq_30221445:
你好 请问这种数据能解吗 <request> ...
Simple XML -
画个逗号给明天qu:
画个逗号给明天qu 写道
Android上传文件到服务器 -
画个逗号给明天qu:
...
Android上传文件到服务器 -
alranger:
我在jsp页面加上这一段代码后,问题还是存在。
解决Ext在ie9报错:不支持extjs对象的“createContextualFragment属性或方法”
该内容转载自:http://android.blog.51cto.com/268543/314262
TableLayout和我们平时在网页上见到的Table有所不同,TableLayout没有边框的,它是由多个TableRow对象组成,每个TableRow可以有0个或多个单元格,每个单元格就是一个View。这些TableRow,单元格不能设置layout_width,宽度默认是fill_parent的,只有高度layout_height可以自定义,默认是wrap_content。
单元格可以为empty,并且通过android:layout_column可以设置index值实现跳开某些单元格。在TableRow之间,添加View,设置layout_height以及背景色,就可以实现一条间隔线。android:layout_span可以设置合并几个单元格:
- <?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">
- <TableRow>
- <TextView
- android:text="column1"
- android:padding="3dip" />
- <TextView
- android:text="column2"
- android:padding="3dip" />
- <TextView
- android:text="column3"
- android:padding="3dip" />
- </TableRow>
- <TableRow>
- <TextView
- android:text="column11"
- android:visibility="invisible"/> //cell不见了
- <TextView
- android:text="左边的invisible"
- android:gravity="right"
- android:padding="3dip" />
- <Button
- android:id="@+id/go"
- android:text="go"
- android:padding="3dip" />
- <Button
- android:text="cancel"
- android:padding="3dip" />
- </TableRow>
- <View //间隔线
- android:layout_height="2dip"
- android:background="#F00" />
- <TableRow>
- <TextView
- android:text="右边的cell empty" />
- <TextView
- android:layout_column="2"
- android:text="跳开empty cell"
- android:padding="3dip" />
- </TableRow>
- <TableRow>
- <TextView
- android:text="合并3个单元格"
- android:layout_span="3"
- android:gravity="center_horizontal"
- android:background="#FFC0C0C0"
- android:textColor="#f00"
- android:padding="3dip" />
- </TableRow>
- </TableLayout>
没有设置收缩/伸展效果
注意,原来没有添加 android:padding="3dip" 的,发现那些column会凑在一起的,没有空白间隔!明显看到,那个cancel按钮被挤到几乎看不见了!这时候需要使用android:shrinkColumns="可收缩的column",android:stretchColumns="可伸展的column"。
android:shrinkColumns和android:stretchColumns的值都是以0开始的index,但必须是string值,即用"1,2,5"来表示。可以用"*"来表示all columns。而且同一column可以同时设置为shrinkable和stretchable。
如果使用TableLayout类的setColumnShrinkable/setColumnStretchable (int columnIndex, boolean isShrinkable)就麻烦些了,需要一个一个column来设置。也可以使用TableLayout的setShrinkAllColumns/setStretchAllColumns来设置all columns。
判断这些column是否shrinkable或stretchable,可以调用isColumnShrinkable/isColumnStretchable(int columnIndex),isShrinkAllColumns()/isStretchAllColumns()。
- <?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="0" > // 设置第一个column可收缩
- <TableRow>
- <TextView
- android:text="column1"
- android:padding="3dip" />
- <TextView
- android:text="column2"
- android:padding="3dip" />
- <TextView
- android:text="column3"
- android:padding="3dip" />
- </TableRow>
- <TableRow>
- <TextView
- android:text="column11"
- android:visibility="invisible"/>
- <TextView
- android:text="左边的invisible"
- android:gravity="right"
- android:padding="3dip" />
- <Button
- android:id="@+id/go2"
- android:text="go2"
- android:padding="3dip" />
- <Button
- android:text="cancel"
- android:padding="3dip" />
- </TableRow>
- <View
- android:layout_height="2dip"
- android:background="#F00" />
- <TableRow>
- <TextView
- android:text="右边的cell empty" />
- <TextView
- android:layout_column="2"
- android:text="跳开empty cell"
- android:padding="3dip" />
- <TextView
- android:text="123456789"
- android:padding="3dip" />
- </TableRow>
- </TableLayout>
可收缩column效果
现在可以看到第一个column为了让第4个column完整显示,而收缩得内容分为几行显示!
而可伸展column的效果就是在其他column可以完整显示时,该column就会伸展,占最多空间:
- <?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:stretchColumns="1"> // 设置第二个column可伸展
- <TableRow>
- <TextView
- android:text="column1"
- android:padding="3dip" />
- <TextView
- android:text="column2"
- android:gravity="right"
- android:padding="3dip" />
- <TextView
- android:text="column3"
- android:padding="3dip" />
- </TableRow>
- <TableRow>
- <TextView
- android:text="column1"
- android:padding="3dip" />
- <TextView
- android:text="column2"
- android:gravity="right"
- android:padding="3dip" />
- <TextView
- android:text="column3"
- android:padding="3dip" />
- </TableRow>
- </TableLayout>
可伸展column效果
而动态隐藏column,可以调用TableLayout.setColumnCollapsed (int columnIndex, boolean isCollapsed)来指定相应的column。另外TableLayout类的boolean isColumnCollapsed (int columnIndex)能够判断指定的column是否隐藏。
TableLayout可以用来做网页上的Form显示效果,看看官方的sample:
- <?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:stretchColumns="1">
- <TableRow>
- <TextView
- android:text="@string/table_layout_10_user"
- android:textStyle="bold"
- android:gravity="right"
- android:padding="3dip" />
- <EditText android:id="@+id/username"
- android:text="@string/table_layout_10_username_text"
- android:padding="3dip"
- android:scrollHorizontally="true" />
- </TableRow>
- <TableRow>
- <TextView
- android:text="@string/table_layout_10_password"
- android:textStyle="bold"
- android:gravity="right"
- android:padding="3dip" />
- <EditText android:id="@+id/password"
- android:text="@string/table_layout_10_password_text"
- android:password="true"
- android:padding="3dip"
- android:scrollHorizontally="true" />
- </TableRow>
- <TableRow
- android:gravity="right">
- <Button android:id="@+id/cancel"
- android:text="@string/table_layout_10_cancel" />
- <Button android:id="@+id/login"
- android:text="@string/table_layout_10_login" />
- </TableRow>
- </TableLayout>
Form效果
本文出自 “学习Android” 博客,请务必保留此出处http://android.blog.51cto.com/268543/314262
发表评论
-
xUtils简介
2014-11-25 10:04 845xUtils 包含了很多实用的android工具。 xU ... -
直接拿来用!最火的Android开源项目
2014-07-25 11:01 701转 http://www.admin10000.com/d ... -
Android APK反编译详解(附图)
2014-03-28 10:56 820http://blog.csdn.net/ithomer/ar ... -
小米人
2014-02-17 17:23 686http://www.xiaomiren.net/ -
android开发之gallery 兑现滚动一张且短距离滑动实现滚动
2013-07-02 15:28 663http://www.myexception.cn/andro ... -
TextView显示插入的图片
2013-07-01 11:29 700http://orgcent.com/android-text ... -
TextView使用SpannableString设置复合文本
2013-07-01 11:29 648http://orgcent.com/android-text ... -
转:::Android TextView文字横向自动滚动(跑马灯)
2013-06-17 11:45 1513TextView实现文字滚动需要以下几个要点: 1.文字长度长 ... -
相片滤镜开源
2013-04-27 15:01 736https://github.com/daizhenjun/I ... -
android图片特效处理之模糊效果
2013-04-27 14:57 829http://blog.csdn.net/sjf0115/ar ... -
android图片处理方法(不断收集中)
2013-04-27 14:57 559http://gundumw100.iteye.com/blo ... -
Android, WindowsPhone7, IOS ,vc2010平台40多套图片滤镜开源
2013-04-27 14:56 665http://www.cnblogs.com/daizhj/a ... -
移动云存储平台
2013-04-25 16:13 906http://bmob.cn 关于Bmob 对于很多 ... -
android ExpandableListView简单应用及listview模拟ExpandableListView
2013-02-28 11:45 693http://blog.csdn.net/jj120522/a ... -
android_App集成支付宝
2013-02-28 11:43 790http://www.cnblogs.com/qianxude ... -
Android Pull Refresh View 插件
2012-12-01 12:43 847Android Pull Refresh View htt ... -
Android-TelephoneManager(转载)
2012-10-09 22:08 1347好文章齐分享。原文地址:http://blog.si ... -
android 开源 listview separato
2012-08-27 22:51 665http://code.google.com/p/androi ... -
fragment开源项目 学习
2012-08-13 12:02 929https://github.com/tisa007/Andr ... -
Fragment学习
2012-08-13 11:53 670http://www.eoeandroid.com/threa ...
相关推荐
•Andorid---UI篇---TableLayout(表格布局) • •Android---UI篇---RelativeLayout(相对布局) • •Android---UI篇---GridView(网格布局) • •Android---UI篇---Gallery(画廊视图) • •Android---UI篇---...
Android UI设计心得。包括线性布局(LinearLayout)、相对布局(RelativeLayout)、表格布局(TableLayout)、框架布局(FrameLayout)、绝对布局(AbsoluteLayout)。其中AbsoluteLayout在Android SDK2.3.3之后已经...
NULL 博文链接:https://yangguangfu.iteye.com/blog/678977
第1部分AndroidUI基础 第1章 入门 1.1 HeUoWorld 1.2 Android应用程序的基本结构 1.2.1文件夹结构 1. 2.2.AndroidManifest 1.2.3 资源 1.3 AndroidUI基础 1.3.1 主屏幕和通知栏1.3.2 XM[布局 1.3.3 ACTIVI'[Y类 ...
你可以学习下在Android开发中,tablelayout 与viewpager如何关联,如何创建每个tag标签对应的Fragment,本源码中是创建5个标题并加入布局中,实际应用中,你可以根据需要添加或减少对应的TAb布局数量。 编译时请...
线性布局LinearLayout 框架布局FrameLayOut RelativeLayout相对布局 绝对布局AbsoluteLayout TableLayout表格布局
线性布局:lineerlayout,相对布局:relativeLayout,表格布局:tablelayout,列表布局:listview(listAdapter),表格布局:gridview(listadapter),imageadapter,绝对布局:absoluteLayout,标签布局:tablayout:1>android....
1. Android有五大布局对象,它们分别是FrameLayout(框架布局:不知道是不是这么翻译的),LinearLayout (线性布局),AbsoluteLayout(绝对布局),RelativeLayout(相对布局),TableLayout(表格布局)。 2. Android常用控件: 1...
15.6 AndroidUI优化 15.7 其他优化 15.7.1 zipalign 15.7.2 图片优化 15.8 小结 第五部分 扩展篇 第16章 Android NDK开发 16.1 AndroidNDK简介 16.2 安装和配置NDK开发环境 16.2.1 系统和软件需求 16.2.2 NDK开发...
具体可以在专栏 【Android开发基础】三种常见的适配器(Adapter)、 【AndroidUI设计】icon矢量图标应用(低内存复应用) 中学习到。 按照折扣,只有第一份享受折扣。(当然还有第n份多少折,其实都很简单,就是for...
3、ANDROID UI LAYOUT 35 3.1、概述 35 3.2、线性布局(LINEAR LAYOUT) 36 3.3、相对布局(RELATIVE LAYOUT) 39 3.4、TABLELAYOUT 40 3.5、ABSOLUTELAYOUT 47 4、ANDROID UI 控件 48 4.1、IMAGEBUTTON 48 4.1.1、...
具体可以在专栏 【Android开发基础】三种常见的适配器(Adapter)、 【AndroidUI设计】icon矢量图标应用(低内存复应用) 中学习到。 按照折扣,只有第一份享受折扣。(当然还有第n份多少折,其实都很简单,就是for...
第4-11罐从“Android视图与容器组件”、“如何控制UI界面”、“Android布局管理器介绍”、“第六大布局特性和演练”四个方面,讲解了Android提供的丰富用户界面组件基础,以及如何使用代码和XML分别控制用户界面。...
4.1 Android UI组件概述 43 4.1.1 View 43 4.1.2 ViewGroup 44 4.1.3 布局管理器 44 4.2 UI设计工具 44 4.2.1 DroidDraw工具 44 4.2.2 ADT插件UI设计工具 46 4.3 事件处理模型 47 4.3.1 接口实现事件处理...
运行: 选运行的设备,可以是模拟器,也可以是真机(如果已经连接好真实手机的话): 模拟器运行: 真实手机调试: 实验二:界面设计:控件与布局 【目的】 Android编程基础,UI设计。 【要求】 1. 了解Android编程...
(2)Android的布局方式有LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、TableLayout(表格布局)。 (3)Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)...
LinearLayout是线性布局控件,它包含的子控件将以横向或竖向的方式排列(通过android:orientation属性来控制),按照相对位置来排列所有的widgets或者其他的containers,超过边界时,某些控件将缺失或消失 ...
15.6 AndroidUI优化 15.7 其他优化 15.7.1 zipalign 15.7.2 图片优化 15.8 小结 第五部分 扩展篇 第16章 Android NDK开发 16.1 AndroidNDK简介 16.2 安装和配置NDK开发环境 16.2.1 系统和软件...