Android基础_页面布局_TableLayout(表格布局)
来源:互联网 发布:cp什么意思网络用语 编辑:程序博客网 时间:2024/05/17 06:42
表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View的对象。TableRow可以添加子控件,每添加一个为一列。
TableLayout属性:
android:collapseColumns:将TableLayout里面指定的列隐藏,若有多列需要隐藏,用逗号将需要隐藏的序列隔开即可。android:collapseColumns="1,3,4";
android:stretchColumns:设置指定的列为可伸展列,以填满剩下的多余的空白空间,若有多列需要设置,用逗号隔开。
android:shrinkColumns:设置指定的列为可收缩列,当可收缩的列太宽时内容不会内挤出屏幕,设置多列用逗号隔开。
TableRow属性:
android:layout_column:设置该控件在TableRow中指定的列。
android:layout_span:设置列占据几列的宽度。
下面放个例子:
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" > <TableLayout android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1" > <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_margin="5dp" android:background="#00868B" /> <EditText android:id="@+id/xml_showPower" android:layout_margin="5dp" android:enabled="false" android:focusable="false" android:gravity="center" android:hint="显示电量" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_margin="5dp" android:background="#00868B" /> <TextView android:layout_width="match_parent" android:layout_margin="5dp" android:gravity="center" android:text="重启、关闭服务、按键检测" /> <TableRow android:gravity="center_vertical" > <Button android:id="@+id/xml_restartService" android:text="重启服务" /> <EditText android:id="@+id/xml_key" android:enabled="false" android:focusable="false" android:hint="检测按键" /> <Button android:id="@+id/xml_closeService" android:text="关闭服务" /> </TableRow> <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_margin="5dp" android:background="#00868B" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:gravity="center" android:text="高频RFID相关测试" /> <TableRow android:gravity="center_vertical" > <Button android:id="@+id/xml_openHRFID" android:text="打开模块" /> <EditText android:id="@+id/xml_HRFIDSN" android:enabled="false" android:focusable="false" android:hint="卡片序列号" /> <Button android:id="@+id/xml_closeHRFID" android:text="关闭模块" /> </TableRow> <TableRow android:gravity="center_vertical" > <Button android:id="@+id/xml_readHData" android:text="读数据" /> <EditText android:id="@+id/xml_showReadHData" android:layout_span="2" android:focusable="false" android:enabled="false" /> </TableRow> <TableRow android:gravity="center_vertical" > <Button android:id="@+id/xml_writeHData" android:text="写数据" /> <EditText android:id="@+id/xml_showWriteHData" android:layout_span="2" android:digits="0123456789abcdefABCDEF" /> </TableRow> <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_margin="5dp" android:background="#00868B" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:gravity="center" android:text="超高频RFID相关测试" /> <TableRow android:gravity="center_vertical"> <Button android:id="@+id/xml_openSRFID" android:text="打开模块"/> <EditText android:id="@+id/xml_SRFIDSN" android:enabled="false" android:focusable="false" android:hint="卡片序列号"/> <Button android:id="@+id/xml_closeSRFID" android:text="关闭模块"/> </TableRow> <TableRow android:gravity="center_vertical"> <Button android:id="@+id/xml_readSRFIDStatus" android:text="询问状态" android:layout_span="3"/> </TableRow> <TableRow android:gravity="center_vertical"> <Button android:id="@+id/xml_readSRFIDPower" android:text="读取功率" /> <EditText android:id="@+id/xml_showReadSRFIDPower" android:enabled="false" android:focusable="false" android:layout_span="2"/> </TableRow> <TableRow android:gravity="center_vertical"> <Button android:id="@+id/xml_writeSRFIDPower" android:text="设置功率" /> <EditText android:id="@+id/xml_showWriteSRFIDPower" android:digits="0123456789" android:maxLength="2" android:layout_span="2"/> </TableRow> </TableLayout></ScrollView>
0 0
- Android基础_页面布局_TableLayout(表格布局)
- Android基础_页面布局_RelativeLayout(相对布局)
- Android基础_页面布局_LinearLayout(线性布局)
- Android基础_页面布局_碎片(Fragment)
- 【Android基础】页面布局
- 表格布局页面
- 表格布局注册页面
- android布局之表格布局
- 基础篇_浅谈Android 布局
- android-TableLayout 表格布局
- Android表格布局
- Android 表格布局
- Android--表格布局
- Android 表格布局<TableLayout>
- android:TableLayout表格布局
- android:TableLayout表格布局
- Android表格布局
- Android TableLayout表格布局
- 详细解析oracle中left join,right join,inner join用法
- MySQL免安装版配置说明
- 如何让sublime编译和运行c和c++代码
- [Java]用递归与非递归的形式输出给定目录的所有文件名
- 项目-旅拍
- Android基础_页面布局_TableLayout(表格布局)
- UVA 442 Matrix Chain Multiplication
- 安卓手机来电亮屏流程分析
- JavaScript-2015.7.27
- HDU 2846 Repository (Trie·统计子串)
- 第三周第一天(【正则表达式的应用】【卖票问题】【同一个账号两人同时取钱】【生产消费问题】【join】【死锁问题】)
- 如此理解面向对象编程
- C++使用libcurl做HttpClient
- UML建模 步骤