收藏 分销(赏)

从头学之布局之表格布局.doc

上传人:天**** 文档编号:3019219 上传时间:2024-06-13 格式:DOC 页数:4 大小:41KB 下载积分:5 金币
下载 相关 举报
从头学之布局之表格布局.doc_第1页
第1页 / 共4页
从头学之布局之表格布局.doc_第2页
第2页 / 共4页


点击查看更多>>
资源描述
TableLayout 类结构图: java.lang.Object ↳ android.view.View ↳ android.view.ViewGroup ↳ android.widget.LinearLayout ↳ android.widget.TableLayout TableLayout没有边框的,它是由多个TableRow对象组成,每个TableRow可以有0个或多个单元格,每个单元格就是一个View。这些TableRow,单元格不能设立layout_width,宽度默认是fill_parent的,只有高度layout_height可以自定义,默认是wrap_content。 android:shrinkColumns设立可以收缩的列号,android:stretchColumns设立可以伸展的列号。需要注意的是列号从0开始,也可以用”*”表达指定所有的列。 TableLayout中的最大列数是所有的位于TableLayout中的TableRow的列数中的最大值,即列数最多的一行有多少列,TableLayout就有多少列。 XML属性 相应方法 描述 android:collapseColumns setColumnCollapsed(intcolumnIndex,booleanisCollapsed) 设立表格的列是否隐藏 android:shrinkColumns setShrinkAllColumns(booleanshrinkAllColumns) 作用:设立表格的列是否收缩(列编号从0开始,下同),多列用逗号隔开(下同),如android:shrinkColumns="0,1,2",即表格的第1、2、3列的内容是收缩的以适合屏幕,不会挤出屏幕。 android:stretchColumns setStretchAllColumns(booleanstretchAllColumns) 设立表格的列是否拉伸 实践: 布局文献: <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="" android:orientation="vertical"android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableLayoutandroid:stretchColumns="1" android:layout_width="fill_parent"android:layout_height="wrap_content"> <TableRow> <TextViewandroid:layout_width="wrap_content" android:layout_height="wrap_content"android:text="姓名"/> <EditTextandroid:text=""android:layout_width="fill_parent" android:layout_height="wrap_content"/> </TableRow> <TableRow> <TextViewandroid:layout_width="wrap_content" android:layout_height="wrap_content"android:text="密码"/> <EditTextandroid:text=""android:layout_width="fill_parent" android:layout_height="wrap_content"/> </TableRow> <TableRow> <Buttonandroid:text="取消"android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Buttonandroid:text="取消"android:layout_width="fill_parent" android:layout_height="wrap_content"/> </TableRow> </TableLayout> </LinearLayout> 这个关于用到了android:stretchColumns它是指定哪一列被拉伸[从0开始],在这里我们指定了为了1,所以出现如下的效果图: 关于动态添加设立TableLayout官方并不推荐所以也不在此阐述,所以在实际开发中,我们一般只用XML来设立布局
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服