[android] 表格布局和绝对布局
2016-02-26 21:49
387 查看
表格布局类似网页中的table tr td,android中是<TableLayout>和<TableRow>
TableRow中的每个控件相当于单元格,并排显示,效果不好,设置layout_width=”0dp”和设置layout_weight这个属性代表的是当前控件渲染的权重,控件的内容如果你想剧中显示,那么设置gravity重心center
格式化快捷键 ctrl+shift+f
表格布局测试:
绝对布局AbsoluteLayout,文档显示不推荐使用,因为android手机种类太多了,屏幕大小不一样,但是在做游戏的时候会使用到,通过layout_x layout_y来定位
TableRow中的每个控件相当于单元格,并排显示,效果不好,设置layout_width=”0dp”和设置layout_weight这个属性代表的是当前控件渲染的权重,控件的内容如果你想剧中显示,那么设置gravity重心center
格式化快捷键 ctrl+shift+f
表格布局测试:
<?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" > <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="哈哈哈" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="嘎嘎嘎" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="哈哈哈" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="嘎嘎嘎" /> </TableRow> </TableLayout>
绝对布局AbsoluteLayout,文档显示不推荐使用,因为android手机种类太多了,屏幕大小不一样,但是在做游戏的时候会使用到,通过layout_x layout_y来定位
相关文章推荐
- 关于一点coding.net与git配合在AndroidStudio/Idea上的使用笔记个的
- Android Listview Collections排序
- android 中如何设置控件的字体和背景样式
- 移植rtmpdump(librtmp)到android
- LinearLayout中layout_weight属性
- [Android]调用字符串资源的几种方法
- 最新的Android SDK安装攻略(动作要快,来晚就失效了)
- Android解析中国天气网的Json数据
- android开发练习三-Retrofit
- Android开发-WIFI实现
- LinearLayout中TextView基准线问题
- 更改手机窗口画面底色
- 根据自己的理解描述下Android数字签名?
- Android NFC开发(二)——Android世界里的NFC所具备的条件以及使用方法
- Android NFC开发(二)——Android世界里的NFC所具备的条件以及使用方法
- HP商务本安装Android Studio时HAXM安装失败并提示需要启动VT-X的问题
- 只需两步,使你的Android Studio支持Lambda表达式(有更新)
- android监听ScrollView滑动停止
- xUtils3简介
- Android保持屏幕常亮的方法总结