TableLayout: 表格布局

一 里面的元素,默认占一行

二 TableLayout 一般和 TableRow 结合在一起用
 TableRow里的内容超出一行的宽度,不会自动换行, 会显示不全

三 常见属性

1 写在父元素上
    collapseColumns : 隐藏第几列的子元素(从0开始数的)
    stretchColumns :拉伸第几列的子元素(从0开始数的),有剩余空间才能拉伸
    shrinkColumns:收缩第几列的子元素(从0开始数的),当这一行的显示超出了,有部分元素显示不全的时候才有效

2 写在子元素上
     layout_column : 设置在第几列显示,该元素后面的元素也会跟着变动
     layout_span :  横向跨几列

一 里面的元素,默认占一行

代码

<?xml version="1.0" encoding="utf-8"?>
<TableLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"xmlns:android="http://schemas.android.com/apk/res/android"><Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableLayout>

效果

二 TableLayout 一般和 TableRow 结合在一起用

TableRow里的内容超出一行的宽度,不会自动换行, 会显示不全

代码

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"><TableRow><Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableRow><TableRow><Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableRow>
<Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/>
<Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableLayout>

三 常见属性

1 写在父元素上
    collapseColumns : 隐藏第几列的子元素(从0开始数的)
    stretchColumns :拉伸第几列的子元素(从0开始数的),有剩余空间才能拉伸
    shrinkColumns:收缩第几列的子元素(从0开始数的),当这一行的显示超出了,有部分元素显示不全的时候才有效
 2 写在子元素上
     layout_column : 设置在第几列显示,该元素后面的元素也会跟着变动
     layout_span :  横向跨几列

代码

<?xml version="1.0" encoding="utf-8"?>
<TableLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:collapseColumns="0"android:stretchColumns="1"android:shrinkColumns="2,5"
xmlns:android="http://schemas.android.com/apk/res/android"><TableRow><Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableRow><TableRow><Buttonandroid:text="第1个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第2个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第3个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第4个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第5个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第6个"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="第7个"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableRow><TableRow><Buttonandroid:text="1"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="2"android:layout_column="4"android:layout_span="3"android:layout_height="wrap_content"android:layout_width="wrap_content"/><Buttonandroid:text="3"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableRow>
<Buttonandroid:text="hello"android:layout_height="wrap_content"android:layout_width="wrap_content"/>
<Buttonandroid:text="girl"android:layout_height="wrap_content"android:layout_width="wrap_content"/></TableLayout>

效果

Android TableLayout 表格布局详解相关推荐

  1. android html 显示表格边框,tablelayout表格布局详解

    如果你已经下载好MT4软件(很多专业外汇平台都有提供下载的),在手机桌面找到图表打开,然后选择好交易商,输入账号密码就可以了. TableLayout怎样实现表格布局 表格布局的子对象不能指定 lay ...

  2. 【转载】TableLayout表格布局详解

    原文地址:http://www.cnblogs.com/manuosex/p/3584701.html 一.Tablelayout简介 Tablelayout类以行和列的形式对控件进行管理,每一行为一 ...

  3. TableLayout表格布局详解

    一.Tablelayout简介 Tablelayout类以行和列的形式对控件进行管理,每一行为一个TableRow对象,或一个View控件. 当为TableRow对象时,可在TableRow下添加子控 ...

  4. android标签table,详解Android TableLayout表格布局

    表格布局的标签是TableLayout,TableLayout继承了LinearLayout.所以它依然是一个线性布局. 前言: 1.TableLayout简介 2.TableLayout行列数的确定 ...

  5. Android六大基本布局详解

    一.基本理论 Android六大基本布局分别是:线性布局LinearLayout.表格布局TableLayout.相对布局RelativeLayout. 层布局FrameLayout.绝对布局Abso ...

  6. android布局置顶_[置顶] Android系统五大布局详解Layout

    我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前,视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit等 ...

  7. android沉浸式布局详解

    原文:https://blog.csdn.net/qq_21806653/article/details/51802 1. 沉浸式布局简介 沉浸,何为沉浸?我所理解的就是让用户身临其境,尽量不被其他环 ...

  8. Android CardView卡片布局详解(八)

    一.CardView简介 CardView卡片布局是Android 5.0之后推出的布局效果,一般用于显示阴影和圆角效果的UI.CardView继承自FrameLayout帧布局,所以它其实还是一个布 ...

  9. TableLayout——表格布局

    学完了线性布局以及相对布局,再看一种比较常见的TableLayout表格布局,当然Android的布局还有帧布局FrameLayout以及绝对布局AbsoluteLayout因为用的比较少,所以不会再 ...

  10. 第15章、布局Layouts之TableLayout表格布局(从零开始学Android)

    TableLayout表格布局 TableLayout是指将子元素的位置分配到行或列中.Android的一个TableLayout有许多TableRow组成,每一个TableRow都会定义一个Row. ...

最新文章

  1. 活动 | 人工智能产学研生态建设研讨会报名开启
  2. 进击谷歌:多线程下程序执行顺序怎么稳定不乱?
  3. JSP2.0语法初步掌握(学习笔记)
  4. Linux ipcs命令与ipcrm命令的用法详解
  5. linux shell if 参数
  6. Virtaulbox虚拟机添加磁盘
  7. cocos creator基础-创建WX开放域遇到的问题
  8. 模拟实现mapset
  9. Introspection in Python How to spy on your Python objects Guide to Python introspection
  10. 十三、PHP框架Laravel学习笔记——构造器的 where 派生查询
  11. java 压缩加密 github_关于Java:使用github中的AES-256-CBC加密
  12. P1287 盒子与球(python3实现)
  13. delphi 中如果不进行 closehandle 会怎么样_报考八一农大的十一大选择之七|带你走进不一样的“信息世界”...
  14. 转载:页面滚动条处理
  15. 2017.9.29 数三角形 思考记录
  16. 改文案、删微博又道歉 广汽蔚来自导自演“比特币购车”乌龙案
  17. redis安装、配置和启动
  18. MySQL高级知识(四)——Explain
  19. 2d unity 多物体 射线_24小时入门Unity游戏开发系列教程
  20. python 接口测试 如何写配置文件_python接口自动化之ConfigParser配置文件的使用详解...

热门文章

  1. 中国兽用化学药品行业“十四五“发展规划及运营模式分析报告2021年版
  2. 机器视觉——光源选型
  3. 安卓ps模拟器_电脑安装模拟器配置要求
  4. 安装JDK11并配置环境变量(附百度网盘下载地址)
  5. 初学者对于SVM的一点点学习心得
  6. ArcGIS利用DEM提取河流水系
  7. AlphaGo增强式学习算法:实现‘高手指点’特效
  8. Excel Mrp生产计划工具
  9. graphpad做单因素方差分析_手把手教你用Graphpad做单因素方差分析
  10. android音乐播放器课程设计报告,音乐播放器课程设计报告