本文来自:http://ipfire.iteye.com/blog/976373

TableLayout说明:

1:TableLyaout 提供了android:layout_span,可以使用此属性让一个单元格跨越多列 ,相当于 HTML 的 colspan属性

2:TableLayout的子控件不能指定android:layout_width="wrap_content",它们会被强制接受fill_parent

3.TableLayout的内容是使用行来定义的,而不是使用列,Android通过查找包含最多单元格的行来确定表格中的列数

测试:

    @Override         public void onCreate(Bundle savedInstanceState) {             super.onCreate(savedInstanceState);             setContentView(R.layout.main);         }  

layout文件:

    <?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="wrap_content"              android:collapseColumns="3,4,5"              android:stretchColumns="1,2"              android:shrinkColumns="0,6"          >                    <TableRow >              <Button  android:text="AA00"/>                                              <Button  android:text="BB11"/>              <Button  android:text="CC22"/>              <Button  android:text="DD33"/>              <Button  android:text="EE44"/>              <Button  android:text="FF55"/>              <Button  android:text="XXXXXXXXXXXXXXXXXX"/>          </TableRow>                    <TableRow >              <Button  android:text="AA00"/>                                              <Button  android:text="BB11"/>              <Button  android:text="CC22"/>              <Button  android:text="XXXXXXXXXXXXXXXXXX"/>                        </TableRow>                              <TableRow >              <Button  android:text="AA00"/>                                              <Button  android:text="BB11" android:layout_span="2"/>              <Button  android:text="CC22"/>                  </TableRow>                              <Button android:text="BUTTON"               android:layout_width="wrap_content"              android:gravity="center"/>      </TableLayout> 

属性说明:

collapseColumns(隐藏)

设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开

1.android:collapseColumns:以第0行为序,隐藏指定的列:把

android:collapseColumns=0,3 意思是把第0和第3列隐藏 ,即AA00,DD33隐藏

stretchColumns(拉伸)

设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)

的列的列索引,多列个用“,”隔开(多列 每列填充空隙大小一样)

当LayoutRow里面的控件已经布满布局时,shrinkColumns不起作用,设置了

stretchColumns="1,2",布局完全没有改变,因为LayoutRow里面已经没有 空间了。

shrinkColumns (收缩)

设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开

当LayoutRow里面的控件还没有布满布局时,shrinkColumns不起作用,设置了

shrinkColumns布局完全没有改变,因为LayoutRow里面还剩足够的

空间。当LayoutRow布满控件时,设置了shrinkColumns,则控件自动向垂直

方向填充空间

更多相关文章

  1. Android(安卓)Studio在Gradle中隐藏Keystore密码
  2. Android中做一个无标题窗口
  3. ListView去掉分割线的几种方法
  4. Android(安卓)VideoView设置静音,Android(安卓)设置VideoView静
  5. RK3326 Android(安卓)8.1 为自己的APK的服务默认开启无障碍权限,
  6. Android学习笔记06:线性布局LinearLayout
  7. Andorid学习笔记(ADT)-常见的UI布局
  8. Android学习笔记06-线性布局LinearLayout
  9. Android(安卓)布局中如何使控件居中

随机推荐

  1. Android activity-alias 多入口配置
  2. android logcat用法总结
  3. 【Android】实现登录、注册、数据库操作(
  4. android中的ANR
  5. 简单学习Android TextView
  6. android软键盘的隐藏以及Edittext的焦点
  7. 状态开关按钮ToggleButton和开关switch的
  8. LeadTools Android 入门教学——运行第一
  9. Android自定义View(自定义控件)
  10. Android 线程池框架、Executor、ThreadPo