Android开发总结笔记 TableLayout(表格布局) 1-1-4
2015-09-22 09:47
651 查看
TableLayout的继承结构
从继承结构就可以看得出来,TableLayout是在LinearLayout的基础上拓展出来的。
表格布局,看字面意思就知道是把子控件用表格的形式呈现出来(TableLayout
API)
xml属性
通常用法
在Tablelayout里面,一个组件表示一行,一个TableRow也表示一行
(TableRow是一个嵌套在TableLayout的一个类,一般跟TableLayout一起出现)
列就看最多子控件的TableRow有多少列就多少列
效果图
加上android:stretchColumns试试(列序号是从0开始的)
第三列就被拉伸开来了。。
试试android:collapseColumns属性
第一列很愉快地被隐藏起来了。。。
最后再来看看这个android:shrinkColumns属性
效果图
第二列很明显被“挤”了。
从继承结构就可以看得出来,TableLayout是在LinearLayout的基础上拓展出来的。
表格布局,看字面意思就知道是把子控件用表格的形式呈现出来(TableLayout
API)
xml属性
通常用法
在Tablelayout里面,一个组件表示一行,一个TableRow也表示一行
(TableRow是一个嵌套在TableLayout的一个类,一般跟TableLayout一起出现)
列就看最多子控件的TableRow有多少列就多少列
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_blue_bright"/>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_green_dark"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_red_dark"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_purple"/>
</TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_orange_dark"/>
</TableLayout>
效果图
加上android:stretchColumns试试(列序号是从0开始的)
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:stretchColumns="2"
android:layout_height="match_parent">
第三列就被拉伸开来了。。
试试android:collapseColumns属性
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:stretchColumns="2"
android:collapseColumns="0"
android:layout_height="match_parent">
第一列很愉快地被隐藏起来了。。。
最后再来看看这个android:shrinkColumns属性
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="1">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_blue_bright"/>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_green_dark"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_red_dark"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_purple"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_green_light"/>
</TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_orange_dark"/>
</TableLayout>
效果图
第二列很明显被“挤”了。
相关文章推荐
- 由Android想到的事情
- Android--颜色,动画效果xml所在目录
- Android多屏幕适配方案
- android压力测试命令monkey详解
- Android 类菜单栏 以及 透明居中排列
- android studio导入别人项目快速配置方式
- 浅析android中的Bundle类
- 加载页面时,判断是安卓手机(android),还是苹果系列(iPhone,iPad,ios)
- Android 墙纸设置代码 详细说明
- 分享:Android清除本地数据缓存代码
- Android 沉浸式状态栏攻略 让你的状态栏变色吧
- Android 沉浸式状态栏攻略 让你的状态栏变色吧
- ubuntu 12.04 x64编译 Android4.4遇到的问题
- Android 地图 —— 百度地图
- Android开发之AlarmManager的使用(开启Activity、开启服务、开启广播)
- Android中getWidth()和getMeasureWidth()的区别探究
- Android中处理崩溃异常
- android 给activity去标题
- Android开发知识点
- Android SwipeRefreshLayout 官方下拉刷新控件介绍