Android_02_表格布局
2015-10-14 12:38
573 查看
代码示例如下:
<?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子节点表示一行,该子节点的每一个子节点都表示一列
TableLayout的一级子节点默认宽都是匹配父元素
TableRow的子节点默认宽高都是包裹内容,所以其子节点的宽高都可以省略不写
android:stretchColumns="1"
表示拉伸第1列,列的索引是从0开始的
android:layout_column="1"
表示改变当前列的索引值为1
其属性提示不出来,需要手动去写
android:layout_span="2"
表示设置当前这一列占据两列的空间
其属性提示不出来,需要手动去写
关于分割线,我们一般用TextView来做:
-->
<TableRow
>
<TextView
android:layout_column="1"
android:text="open"
/>
<TextView
android:gravity="right"
android:text="Ctrl-O"
/>
</TableRow>
<TableRow >
<TextView
android:layout_column="1"
android:text="save"
/>
<TextView
android:gravity="right"
android:text="Ctrl-S"
/>
</TableRow>
<TableRow
>
<TextView
android:layout_column="1"
android:text="save AS"
/>
<TextView
android:text="Ctrl-shift-S"
/>
</TableRow>
<TextView
android:layout_height="1dp"
android:background="#000000"
/>
<TableRow
>
<TextView
android:text="X"
/>
<TextView
android:layout_span="2"
android:text="Import"
/>
</TableRow>
<TableRow
>
<TextView
android:text="X"
/>
<TextView
android:text="Export"
/>
<TextView
android:gravity="right"
android:text="Ctrl-E"
/>
</TableRow>
<TextView
android:layout_height="1dp"
android:background="#000000"
/>
<TableRow
>
<TextView
android:layout_column="1"
android:layout_span="2"
android:text="Quit"
/>
</TableRow>
</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="1"
>
<!--
表格布局:
每有一个TableRow子节点表示一行,该子节点的每一个子节点都表示一列
TableLayout的一级子节点默认宽都是匹配父元素
TableRow的子节点默认宽高都是包裹内容,所以其子节点的宽高都可以省略不写
android:stretchColumns="1"
表示拉伸第1列,列的索引是从0开始的
android:layout_column="1"
表示改变当前列的索引值为1
其属性提示不出来,需要手动去写
android:layout_span="2"
表示设置当前这一列占据两列的空间
其属性提示不出来,需要手动去写
关于分割线,我们一般用TextView来做:
-->
<TableRow
>
<TextView
android:layout_column="1"
android:text="open"
/>
<TextView
android:gravity="right"
android:text="Ctrl-O"
/>
</TableRow>
<TableRow >
<TextView
android:layout_column="1"
android:text="save"
/>
<TextView
android:gravity="right"
android:text="Ctrl-S"
/>
</TableRow>
<TableRow
>
<TextView
android:layout_column="1"
android:text="save AS"
/>
<TextView
android:text="Ctrl-shift-S"
/>
</TableRow>
<TextView
android:layout_height="1dp"
android:background="#000000"
/>
<TableRow
>
<TextView
android:text="X"
/>
<TextView
android:layout_span="2"
android:text="Import"
/>
</TableRow>
<TableRow
>
<TextView
android:text="X"
/>
<TextView
android:text="Export"
/>
<TextView
android:gravity="right"
android:text="Ctrl-E"
/>
</TableRow>
<TextView
android:layout_height="1dp"
android:background="#000000"
/>
<TableRow
>
<TextView
android:layout_column="1"
android:layout_span="2"
android:text="Quit"
/>
</TableRow>
</TableLayout>
实际效果如下:
相关文章推荐
- 魅蓝note 做Android真机调试
- android计量单位--dip、px、sp之间区别与联系
- Android ndk报错error: format not a string literal and no format arguments [-Werror=format-security]
- Android 四大组件之BroadcastReceiver(发送有序无序广播)
- android程序的安装与卸载
- android程序的安装与卸载
- 【Android】No resource found that matches the given name 'Theme.Sherlock.Light.NoActionBar'
- Android中string.xml文件中设置部分字体颜色大小
- Android 学习OpenGL ES
- Android保存图片到系统图库
- Android Fragment实现导航栏
- 如果字符串是科学:如123213e21,转化为字符串
- android.os.NetworkOnMainThreadException
- 工欲善其事必先利其器之Android环境搭建
- 将字符串三位一个逗号显示
- Android 通过Service单独进程模仿离线推送 Server Push
- 【总结】Mac版Android Studio常用快捷键总结
- android中横竖屏切换状态保持一致
- SEAndroid安全机制对Binder IPC的保护分析
- SEAndroid安全机制对Android属性访问的保护分析