前端之家收集整理的这篇文章主要介绍了
[android] 表格布局和绝对布局,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
404_0@/*****************2016年4月28日 更新*************************************/
@H_
404_0@
知乎:为什么Android没有像iOS一样提供autolayout方法来对付屏幕的适配性问题?
@H_
404_0@
@H_
404_0@
stormzhang:
@H_
404_0@和Android的屏幕适配来比autoLayout简直弱爆了好么?Android中的RelativeLayout,layout_weight
属性,dp/sp单位,mdpi/hdpi/xdpi等一系列
文件夹,提供了各种手段
解决适配问题,小到Android Wear,大到Android TV都可以完美适配…
@H_
404_0@/******************************************************/
@H_
404_0@表格布局类似网页中的
table tr td,android中是<TableLayout>和<TableRow>
@H_
404_0@
@H_
404_0@TableRow
中的每个控件相当于单元格,并排显示,效果不好,设置layout_width=”0dp”和设置
layout_weight这个属性代表的是当前控件渲染的权重,控件的内容如果你想剧中显示,那么设置gravity重心center
@H_
404_0@
@H_
404_0@格式化快捷键
ctrl+shift+f
@H_
404_0@
表格布局测试:
<?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
android:layout_height="wrap_content" >
TextView
="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="哈哈哈" />
="嘎嘎嘎" />
</TableRow>
TableLayout>
@H_
404_0@绝对布局
AbsoluteLayout,文档显示不推荐使用,因为android手机种类太多了,屏幕大小不一样,但是在做游戏的时候会使用到,通过layout_x layout_y来定位
@H_
404_0@