Android笔记(十) Android中的布局——表格布局
TableLayout运行我们使用表格的方式来排列控件,它的本质依然是线性布局。表格布局采用行、列的形式来管理控件,TableLayout并不需要明确的声明包含多少行多少列,而是通过添加TableRow、其他组件来控制表格的行数和列数。
每次向Table中添加一个TableRow,该TableRow就是一个表格行,TableRow也是容器,因此它也可以不断的添加其他组件,每添加一个子组件该表格就增加一列。
实例代码,实现一下简单的登录界面
tablelayout.xml
<?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="1"> <TableRow>
<TextView android:layout_height="wrap_content"
android:text="账户:"/>
<EditText
android:id="@+id/usernameInput"
android:layout_height="wrap_content"
android:hint="输入要注册的用户名"/>
</TableRow> <TableRow>
<TextView android:layout_height="wrap_content"
android:text="密码:"/>
<EditText
android:id="@+id/passwordInput"
android:layout_height="wrap_content"
android:hint="输入要密码"/>
</TableRow> <TableRow>
<Button
android:id="@+id/loginButton"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="登录"/>
</TableRow>
</TableLayout>
显示结果为:

显然,太丑了,我们想要在左右两边都有一定的间距,并且所有组件都位于屏幕中间,这里就需要一些属性来配合达到这些效果。
android:collapseColumns="0"——隐藏第0列
android:shrinkColumns="0"——收缩第0列
android:stretchColumns="0"——拉伸第0列
Android笔记(十) Android中的布局——表格布局的更多相关文章
- Android 笔记之 Android 系统架构
Android笔记之Android系统架构 h2{ color: #4abcde; } a{ color: blue; text-decoration: none; } a:hover{ color: ...
- 第24讲 UI_布局 之帧布局 表格布局 绝对布局
第24讲 UI_布局 之帧布局 表格布局 绝对布局 3. FrameLayout(帧布局) 帧布局是从屏幕的左上角(0,0)坐标开始布局,多个组件层叠排序,后一个组件总会将前一个组件所覆盖,除非最后一 ...
- Android布局— — —表格布局
表格布局 以表格的形式来显示界面中的控件,表格的每一行为一个TableRow,每当一个控件添加到TableRow中,就生成一个单元格. 语法格式: <TableLayout xmlns:andr ...
- Android学习十---Android Camera
Android camera用来拍照和拍摄视频的先看一下最后实现的效果图 最后的效果图 一.准备 在你的应用程序上使用android拍照设备,需要考虑以下几个方面 1. 是否是 ...
- 《MFC游戏开发》笔记十 游戏中的碰撞检测进阶:地图类型&障碍物判定
本系列文章由七十一雾央编写,转载请注明出处. http://blog.csdn.net/u011371356/article/details/9394465 作者:七十一雾央 新浪微博:http:// ...
- Android笔记: Android版本号
由于有2套版本号 总是对应不准 记下来做过标记 Android 4.3 ----18 Android 4.2---17 Android 4.1---16 Android 4.0.3---15Andro ...
- Android笔记:java 中的数组
在与嵌入式设备通讯的过程中使用的socket通讯 获取的字节流,通常转换为字节数组,需要根据协议将字节数组拆分.对于有规律的重复拆分可以使用,由于java中不能像c中直接进行内存操作例如使用struc ...
- Android笔记:java 中的枚举
部分数据使用枚举比较方便,java中的enmu不如c#中使用方便 记录备忘 以c#中的代码为例 public enum PlayState { /// <summary> /// 关闭 / ...
- Android笔记之Fragment中创建ViewModel的正确方式
之前一直都是这么写的 pageViewModel = ViewModelProviders.of(this).get(PageViewModel.class); //参数this是当前fragment ...
随机推荐
- cookie加载不正确的问题
华为系统更新后安装了一个谷歌6月安全补丁的东西,然后之前写的调h5页面的部分就出现了问题,后台查过发现是Android端调h5页面时cookie没能带过去,导致了登录失败.于是对setCookie部分 ...
- HTML布局排版之制作个人网站的文章列表
文章列表.博文列表,一般是有文章名字和时间构成的,文章名字后面是时间,点击文章的名字,可进入该文章.为了美观,一般文章名字都有一定的最大字数限制,长宽对齐,等长宽的统一格式比较美观,这种用表格来做比较 ...
- vuex中mutations数据响应
vuex中的mutation需遵守Vue的响应规则: 既然Vuex的store中的状态是响应式的,那么在我们变更状态时,监视状态的Vuex最好在state中初始化好所有的所需属性. 如果需要在对象上添 ...
- 13点睛Spring4.1-Spring EL
13.1 Spring EL Spring EL-Spring表达式语言,支持在xml和注解中使用表达式,类似jsp的EL表达式语言; 本教程关注于在注解中使用Spring EL; Spring EL ...
- Office 2010 经验总结
1. 如何设置蓝底白字? 答:点击菜单项上的"页面布局"→"页面颜色",就可以选择喜欢的页面颜色,字体颜色也会跟着发生改变. 补充:如果不喜欢相应的页面颜色中系 ...
- 使用Jedis出现Connection refused的解决方案
1.修改redis.conf配置文件中的 bind 127.0.0.1 为本机外网IP: 2. cluster-enabled yes 设置是否集群操作,如果是的话开启 yes,否的话 设置n ...
- linux c基础技巧
C语言:向文件末尾进行追加数据https://blog.csdn.net/qq_31243065/article/details/82354557 https://zhidao.baidu.com/q ...
- 守护进程daemon
# -*- coding: utf-8 -*- import sys, os, time, atexit from signal import SIGTERM class Daemon: def __ ...
- nginx tar包安装 包含openssl,rewrite,stream,sticky 等模块
最近需要使用nginx 但是发现有时缺少一些模块. 所以 在学习如何增加上相应的模块. 主要学习的网站: 沧海书生 Ansible爱好者 https://www.cnblogs.com/tssc/p/ ...
- maven profiles多环境配置
maven profiles多环境配置 转载. https://blog.csdn.net/runbat/article/details/81747874 今天做了一个小项目,需要配置开发.测试.预发 ...