TableLayout的使用
来源:互联网 发布:网络主播直播内容策划 编辑:程序博客网 时间:2024/04/26 03:22
我平时常用的布局为LinearLayout,RelativeLayout,Framelayout。很少使用TableLayout。感觉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:gravity="center" android:padding="10dp" android:stretchColumns="1"> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="用户名:" android:textSize="30dp" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入用户名" /> </TableRow> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密码:" android:textSize="30dp" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入密码" android:inputType="textPassword" /> </TableRow> <TableRow> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_span="2" android:text="登录" /> </TableRow></TableLayout>
在 TableLayout 中每加入一个 TableRow 就表示在表格中添加了一行,然后在 TableRow中每加入一个控件,就表示在该行中加入了一列,TableRow 中的控件是不能指定宽度的。这里我们将表格设计成了三行两列的格式,第一行有一个 TextView 和一个用于输入账号的EditText,第二行也有一个 TextView 和一个用于输入密码的 EditText,我们通过将android:inputType属性的值指定为 textPassword,把 EditText 变为密码输入框。可是第三行只有一个用于登录的按钮,前两行都有两列,第三行只有一列,这样的表格就会很难看,而且结构也非常不合理。这时就需要通过对单元格进行合并来解决这个问题,使用android:layout_span=”2”让登录按钮占据两列的空间,就可以保证表格结构的合理性了。
这里将 android:stretchColumns 的值指定为 1,表示如果表格不能完全占满屏幕宽度,就将第二列进行拉伸
0 0
- TableLayout的使用
- TableLayout的简单使用
- TableLayout的使用
- Android TableLayout的使用
- TableLayout的使用
- TableLayout的使用
- TableLayout的使用
- tablelayout的使用
- TableLayout和TableRow的使用
- TableLayout表格简单的使用
- TableLayout和ViewPager的使用
- TableLayout的基本使用方式
- TableLayout的使用注意项
- tablelayout 使用
- 使用TableLayout
- 表格布局(TableLayout)的简单使用
- android表格布局TableLayout的使用
- TableLayout的使用来制作表格
- 在android使用OPENGL总结
- mysql分区及实例演示
- PostgreSQL之With语句
- Azkaban-开源任务调度程序(使用篇)
- Bestcoder Pro.ID 2003 求绝对值
- TableLayout的使用
- msyql 锁等待 解决方案
- ES6-Object的变化
- bzoj1455: 罗马游戏
- setTimeout(fn, 15)这样的东西到底有没有意义?
- 获取整数在虚拟机中的补码
- CKEditor和CKFinder
- Android自定义GridView之仿支付宝首页可拖动、可删除的九宫格
- Azkaban2.5.0与Hadoop2.5.1的集成