TableLayout说明:

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

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

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

测试:

java代码:

 @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 TextView的字体颜色设置的多种方法
  2. android 圆形头像—— android开源系列:CircleImageView自定义圆
  3. TextView关于xml属性用法(待完善)
  4. android 模拟器键盘控制键 以及 设置模拟器屏幕大小
  5. GridView的属性
  6. Android(安卓)Studio中与网站通信
  7. 转:Android(安卓)设置EditText光标颜色及粗细
  8. Android(安卓)如何实现带滚动条的TextView,在更新文字时自动滚动
  9. android shape的使用

随机推荐

  1. Android 显示、隐藏状态栏和导航栏
  2. build android toochain on mac (gcc 4.4.
  3. android google地图开发总结——获取goog
  4. android adb 启动各种应用
  5. Android作为CXF客户端调用服务端。
  6. Android Audio代码分析13 - AudioTrack::
  7. Android 与H5交互心得(Base64图片)
  8. Android 实现闪屏页和右上角的倒计时跳转
  9. Android(安卓)4.4无法写sdcard解决方案
  10. Android 复制到剪切板功能