1、相关属性

1.1、常用属性
android:collapseColumns 设置需要被隐藏的列的序列号
android:shrinkColumns 设置允许被收缩的列的序列号
android:stretchColumns 设置运行被拉伸的列的序列号 注意: 列号都是从0开始算,设置多个“1,3”,所有列都生效“*”
android:layout_column = ”2“ 表示跳过第二个
android:layout_span = ”4“ 表示合并4个单元格 1.2、如何确定行数和列数
!如何直接往TableLayout中添加组件的话,那个这个组件将占满一行
!如何想一行有多个组件,就添加一个TableRow的容器,把组件放进去
!tablerow中组件个数决定列数,列的宽度由最宽的单元格决定
!TableRow的宽度是默认的不能修改,高度可以自定义
!整个表格布局的宽度取决于父容器的宽度

2、示例

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity"
android:stretchColumns="0,3"
android:gravity="center_vertical"
android:background="#66ff66"> <TableRow>
<TextView />
<TextView
android:layout_height="wrap_content"
android:text="用户名:"/>
<EditText
android:layout_height="wrap_content"
/>
<TextView />
</TableRow> <TableRow>
<TextView />
<TextView
android:layout_height="wrap_content"
android:text="密 码"/>
<EditText
android:layout_height="wrap_content"
android:minWidth="200dp"/>
<TextView />
</TableRow> <TableRow>
<TextView /> <Button
android:layout_height="wrap_content"
android:text="登录"/>
<Button
android:layout_width="60dp"
android:text="退出"/>
<TextView />
</TableRow> </TableLayout>

效果图

Android之TableLayout表格布局的更多相关文章

  1. android:TableLayout表格布局详解

    1.TableLayout简介2.TableLayout行列数的确定3.TableLayout可设置的属性详解4.一个包含4个TableLayout布局的实例及效果图一.Tablelayout简介  ...

  2. Android 自学之表格布局 TableLayout

    表格布局(TableLayout),表格布局采用行.列的形式来管理UI组件,TableLayout并不需要明确的声明多少行,多少列,而是通过TableRow.其他组件来控制表格的行数和列数. 每次想T ...

  3. Android零基础入门第29节:善用TableLayout表格布局,事半功倍

    原文:Android零基础入门第29节:善用TableLayout表格布局,事半功倍 前面学习了线性布局和相对布局,线性布局虽然方便,但如果遇到控件需要排列整齐的情况就很难达到要求,用相对布局又比较麻 ...

  4. 【转】TableLayout(表格布局)

    转自:http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864536.html TableLayout(表格布局) 表格布局模型以行列的形式管 ...

  5. .Net程序猿玩转Android开发---(8)表格布局TableLayout

    表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...

  6. Android中的表格布局TableLayout

    表格布局最基本的三个属性: XML代码实例: <?xml version="1.0" encoding="utf-8"?> <LinearLa ...

  7. android的布局-----TableLayout(表格布局)

    学习导图 (1)TableLayout的相关简介 java的swing编程和html中经常会使用到表格,可见表格的应用开发中使用还是比较多的,同样android也为我们提供这样的布局方式. (2)如何 ...

  8. Android布局-TableLayout表格布局

    一.表格布局-TableLayout 1.概念 表格布局采用行列的形式来管理UI的控件.表格布局适合于有规则的布局. TableRow,用来管理行,TableRow中的一个空间占据该行的一列.若不用T ...

  9. android:TableLayout表格布局详解

    http://blog.csdn.net/justoneroad/article/details/6835915 这篇博文包括的内容:1.TableLayout简介2.TableLayout行列数的确 ...

随机推荐

  1. LeetCode 31. Next Permutation【Medium】

    Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...

  2. _IRP struct

    Windows XP x86 +0x000 Type : Int2B +0x002 Size : Uint2B +0x004 MdlAddress : Ptr32 _MDL +0x000 Next : ...

  3. python对urlEncode进行解码

    利用python自带的urlib进行编码和解码,没有什么问题.(https://www.hustyx.com/python/) 但如果是用url编码工具(http://tool.chinaz.com/ ...

  4. XYIXY.COM短网址在线生成,快速、稳定、永久有效,免费开放网址缩短API接口。

    在PHP中使用API 要在PHP程序中使用API,您必须通过file_get_contents或cURL发送GET请求:两者都是可靠的方法,您可以直接复制下面的代码. <?php /**** S ...

  5. leetcode-229-求众数②

    题目描述: 方法一:摩尔投票法 class Solution: def majorityElement(self, nums: List[int]) -> List[int]: candiate ...

  6. 阿里云应用上边缘云解决方案助力互联网All in Cloud

    九月末的杭州因为一场云栖大会变得格外火热. 9月25日,吸引全球目光的2019杭州云栖大会如期开幕.20000平米的展区集结数百家企业,为数万名开发者带来了一场前沿科技的饕餮盛宴. 如同往年一样,位于 ...

  7. HttpClient 使用案例

    package com.qifeng.config.ygx.common.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fas ...

  8. 有关axios的request与response拦截

    // http request 拦截器 axios.interceptors.request.use( config => { var token = localStorage.getItem( ...

  9. nodejs与websocket模拟简单的聊天室

    nodejs与websocket模拟简单的聊天室 server.js const http = require('http') const fs = require('fs') var userip ...

  10. sql还原数据库时候改变数据库名

    需求:在做图书馆数据整合时候,由于有两个校区,用的是分离开的同一个数据库,数据库名字都一样的,现在我要整合在一起,我的想法是把两个数据库先还原到我本地,用写好的脚本整合到一起.所以,我还原两个数据库时 ...