表格布局TableLayout

简单实现计算机界面布局的案例:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"> //android:stretchColumns="*"填满多余空间的属性
<TextView
android:gravity="right|center" //textView1的文字居右然后居中
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp" //设置高度
android:text="90" />
<TableRow //表格行
android:layout_weight="1" //设置权重之后就能平均分配整个屏幕 ,如果不设置就有空白处
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="match_parent" //高度要设为match_parent 不然按钮就不会占满行
android:text="7" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="8" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="9" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="/" />
</TableRow>
<TableRow
android:layout_weight="1"
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="4" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="5" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="6" />
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="*" />
</TableRow>
<TableRow
android:layout_weight="1"
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="1" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="2" />
<Button
android:id="@+id/button11"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="3" />
<Button
android:id="@+id/button12"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="-" />
</TableRow>
<TableRow
android:layout_weight="1"
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button13"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="0" />
<Button
android:id="@+id/button14"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="." />
<Button
android:id="@+id/button15"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+" />
<Button
android:id="@+id/button16"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="=" />
</TableRow>
<TableRow
android:layout_weight="1"
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:layout_span="4" //最后一行只有一个按钮,设置android:layout_span就说明占4个位置(全部沾满)
android:id="@+id/button17"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="clear" />
</TableRow>
</TableLayout>
完成之后

表格布局TableLayout的更多相关文章
- .Net程序猿玩转Android开发---(8)表格布局TableLayout
表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...
- Android 自学之表格布局 TableLayout
表格布局(TableLayout),表格布局采用行.列的形式来管理UI组件,TableLayout并不需要明确的声明多少行,多少列,而是通过TableRow.其他组件来控制表格的行数和列数. 每次想T ...
- Android课程---表格布局TableLayout
特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...
- Android布局_表格布局TableLayout
一.TableLayout概述 TableLayout表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View的对象 二.TableLayout的全局属性 1 ...
- Android 表格布局<TableLayout>
表格布局即,tableLayout,表格布局通过行.列的形式来管理UI组件,TablelLayout并不需要明确地声明包含多少行.多少列,而是通过TableRow,以及其他组件来控制表格的行数和列数, ...
- Android开发5:布局管理器2(表格布局TableLayout)
版本:Android4.3 API18 学习整理:liuxinming 概念 TableLayout继承了LinearLayout,因此它的本质依然是线性布局管理器. 表格布局采 ...
- Android中的表格布局TableLayout
表格布局最基本的三个属性: XML代码实例: <?xml version="1.0" encoding="utf-8"?> <LinearLa ...
- Android——布局(线性布局linearLayout,表格布局TableLayout,帧布局FrameLayout)
线性布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:androi ...
- Android 表格布局 TableLayout
属性介绍 stretchColumns:列被拉伸 shrinkColumns:列被收缩 collapseColumns:列被隐藏 举例测试 <TableLayout android:id=&qu ...
- 界面布局之表格布局TableLayout+TableRow
一.基础知识: TableLayout置底,TableRow在TableLayout的上面,而Button.TextView等控件就在TableRow之上, 另外,TableLayout之上也可以单独 ...
随机推荐
- ajax使用中发现的问题与深入扩展(for循环中嵌套ajax)
在学习ajax的过程中,我曾经遇到过这样的一个问题,为了得到一个详情列表,我要先向服务器去请求得到索引表,简单描述就是ajax中的success中的for循环中再次嵌套了ajax,结果第二层succe ...
- [转]mysql自动定时备份数据库的最佳方法-支持windows系统
网上有很多关于window下Mysql自动备份的方法,可是真的能用的也没有几个,有些说的还非常的复杂,难以操作. 我们都知道mssql本身就自带了计划任务可以用来自动备份,可是mysql咱们要怎么样自 ...
- java.lang.reflection打印一个类的全部信息
package com.ljy.chapter5; import java.lang.reflect.Constructor; import java.lang.reflect.Field; impo ...
- cmd 命令行下复制、粘贴的快捷键
1.单击左下角“开始”菜单,选择“运行”,输入“cmd”. 2.在弹出的cmd窗口的标题栏上点击“右键”,选择“属性”. 3.在弹出的对话框中选择“选项”这个选项卡,在“编辑选项”区域中勾选“快速编辑 ...
- 本大神教你用PHP把文本内容转换成16进制数字,进行加密
<?php $a="杨波"; $b = bin2hex($a); echo $a."<br />"; $c = pack("H*&q ...
- prototype/constructor/__proto__之prototype简单应用
一.简单使用构造原型加prototype造简单的轮子. 1.想jQ那样获取HTML元素,先看JS代码 function Cmf() { //创建构造函数 this.arry = [] } Cmf.pr ...
- ThinkPHP接入支付宝支付功能
最近做系统,需要实现在线支付功能,毫不犹豫,选择的是支付宝的接口支付功能.这里我用的是即时到帐的接口,具体实现的步骤如下: 一.下载支付宝接口包 下载地址:https://b.alipay.com/o ...
- php函数——『解析 xml数据』
<?php //该文件是 //$raw_post_data = file_get_contents('php://input'); //file_put_contents('a.txt', $r ...
- Python入门,新手之路
1.开始使用Python: 从上一篇中我们提到了第一个Python,print("Hello World!")程序说起,看到这一句话,你有没有想过如果括号中的语句不是Hello W ...
- 显示Mac电脑下的隐藏文件
1. 在应用程序里打开终端, cd 你的文件夹名 ls -a 即可显示该文件夹下的所有隐藏文件 2. 如果你想打开整个系统的隐藏文件可以在终端下输入以下命令 defaults write com.ap ...