`
825288003
  • 浏览: 110875 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

TableLayout里的一些属性

阅读更多
TableLayout 常用的三个XMl配置:
1.collapseColumns - 设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
2.stretchColumns - 设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)的列的列索引,多个用“,”隔开
3.shrinkColumns - 设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开

TableRow 中的内容:
单元格可以为empty,并且通过android:layout_column可以设置index值实现跳开某些单元格。在 TableRow之间,添加View,设置layout_height以及背景色,就可以实现一条间隔线。android:layout_span可以设置合并几个单元格

实例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="*">

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <TextView android:text="column1" android:padding="3px"/>
            <TextView android:text="column2" android:padding="3px"/>
            <TextView android:text="column3" android:padding="3px"/>
            <TextView android:text="column4" android:padding="3px"/>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <TextView android:text="invisible" android:visibility="invisible"/>
            <TextView android:text="... ..." android:gravity="center" android:padding="3px"/>
            <TextView android:text="... ..." android:padding="3px" android:gravity="center"/>  
            <TextView android:text="... ..." android:padding="3px" android:gravity="center"/>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <TextView android:text="... ..." android:gravity="center"/>  
            <TextView android:text="... ..." android:layout_column="2" android:gravity="center"/> 
            <TextView android:text="... ..." android:layout_column="3" android:gravity="center"/>   
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <TextView android:text="... ... ... ... ... ... ... ..." android:layout_span="4" android:gravity="center"/>  
        </TableRow>
    </TableLayout>

</LinearLayout>

运行结果



分享到:
评论

相关推荐

    Android移动应用开发表格布局TableLayout的常用属性.pdf

    Android移动应用开发表格布局TableLayout的常用属性.pdf 学习资料 复习资料 教学资源

    Android开发笔记 TableLayout常用的属性介绍

    TableLayout经常用到的属性有: android:collapseColumns:以第0行为序,隐藏指定的列: android:collapseColumns该属性为空时,效果如下图: 把android:collapseColumns=0,2————–》意思是把第0和第2列去掉,...

    Android布局之表格布局TableLayout详解

    2.TableLayout的属性(全局属性) android:collapseColumns=”1,2” 隐藏从0开始的索引列,列之间必须用逗号隔开1,2 android:shrinkColumns=”1,2” 收缩从0开始的索引列,当可收缩的列太宽(内容太多时)不会...

    详解Android TableLayout表格布局

    3、TableLayout可设置的属性详解 4、一个包含4个TableLayout布局的实例及效果图 &lt;?xml version=1.0 encoding=utf-8?&gt; &lt;LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:...

    Android布局之TableLayout表格布局

    三个常用的属性 android:collapseColumns:设置需要被隐藏的列的序号 android:shrinkColumns:设置允许被收缩的列的列序号 android:stretchColumns:设置运行被拉伸的列的列序号 学习导图 (1)TableLayout的相关简介 ...

    Android开发之TableLayout表格布局

    TableLayout属性: android:collapseColumns:将TableLayout里面指定的列隐藏,若有多列需要隐藏,请用逗号将需要隐藏的列序号隔开。  android:stretchColumns:设置指定的列为可伸展的列,以填满剩下的多余空白空间...

    详解CSS的table-layout属性的用法

    今天给大家详细说一下table-layout属性的用法, tableLayout属性用来显示表格单元格、行、列的算法规则。本文通过实例代码给大家介绍了CSS的table-layout属性的用法,需要的朋友参考下吧

    Android布局(RelativeLayout、TableLayout等)使用方法

    本文介绍 Android 界面开发中最基本的四种布局LinearLayout、RelativeLayout、FrameLayout、TableLayout 的使用方法及这四种布局中常用的属性。 LinearLayout 线性布局,布局中空间呈线性排列 RelativeLayout 相对...

    详解Android TableLayout中stretchColumns、shrinkColumns的用法

    android:stretchColumns=”1″ android:shrinkColumns=”1″这两个属性是TableLayout所特有的,也是这两个属性影响了子对象的布局。 表格布局是按照行列来组织子视图的布局。表格布局包含一系列的Tabrow对象,用于...

    Android常用布局属性介绍

    Android中布局属性的简单介绍,LinearLayout,RelativeLayout ,TableLayout ,4.AbsoluteLayout ,5.FrameLayout 布局控件TextView ,Edittext ,Button ,Shape ,CheckBox,RadioGroup,Spinner,TimePicker,...

    Android应用中通过Layout_weight属性用ListView实现表格

    今天主要说的是对Layout_weight属性的完全解析,以及利用Layout_weight这个属性使用ListView来实现表格的效果,我们都知道Android里面专门有一个TableLayout来实现表格的,说实话,我平常开发中用TableLayout还是...

    Android控件布局(浅谈5种布局)

    布局的类型:LinearLayout(线性布局)、RelativeLayout(相对布局)、FrameLayout(帧布局)、TableLayout(表格布局)、Absolute(绝对布局) 1.LinearLayout线性布局:主要以水平和竖直方式来显示界面中的控件。...

    Android 布局文件Layout XML属性

    Android有Layout:FrameLayout,LinearLayout,TableLayout,RelativeLayout,AbsoluteLayout。 放入Layout中进行排布的View的XML属性: 几种Layout中Item所共有的XML属性:  (1)layout_width  (2)layout_height  ...

    Android 五大布局方式详解

    表格布局(TableLayout):按照行列方式布局组件。 相对布局(RelativeLayout):相对其它组件的布局方式。  绝对布局(AbsoluteLayout):按照绝对坐标来布局组件。  1. 线性布局 线性布局是Android开发中最...

    Android Studio实现简易计算器(表格布局TableLayout)

    第一个是文件名字,第二个属性可以自己选择,我们这里前两个文件选择shape,第三个文件选selector,附上颜色背景代码 gray.xml &lt;?xml version=1.0 encoding=utf-8?&gt; &lt;shape xmlns:android=http://schemas.

    css table-layout属性显示表格单元格、行、列的算法规则

    定义和用法 tableLayout 属性用来显示表格单元格、行、列的算法规则。 固定表格布局: 固定表格布局与自动表格布局相比,允许浏览器更快地对表格进行布局。 在固定表格布局中,水平布局仅取决于表格宽度、列宽度、...

Global site tag (gtag.js) - Google Analytics