[android] 表格布局和绝对布局
2023-02-18 15:47:13 时间
/*****************2016年4月28日 更新*************************************/
知乎:为什么Android没有像iOS一样提供autolayout方法来对付屏幕的适配性问题?
stormzhang:
和Android的屏幕适配来比autoLayout简直弱爆了好么?Android中的RelativeLayout, layout_weight属性,dp/sp单位,mdpi/hdpi/xdpi等一系列文件夹,提供了各种手段解决适配问题,小到Android Wear,大到Android TV都可以完美适配…
/******************************************************/
表格布局类似网页中的table tr td,android中是<TableLayout>和<TableRow>
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来定位
相关文章
- H5加载Android本地路径图片
- ReactNative-Android插件
- 原有Android项目中体验Flutter
- 在AndroidStudio中开启Show Context Actions对Dart的支持
- Android开发——adb连接夜神模拟器
- Android项目刮刮奖详解扩展篇——开源刮刮奖View的制作
- Android项目刮刮奖详解(四)
- Android项目刮刮奖详解(三)
- Android项目刮刮奖详解(二)
- Android项目刮刮奖详解(一)
- Android开发——Drawable与Bitmap知识
- Android开发——绘图基础
- Android破解学习之路(八)—— 进化之地内购破解
- Android破解学习之路(九)—— 练手破解游戏集合
- Android开发——使用自带图标
- 教我徒弟Android开发入门(四)
- Android安全–加强版Smali Log注入
- Android APK 签名文件MANIFEST.MF、CERT.SF、CERT.RSA分析
- Android安全–检测是否为Android模拟器
- Android安全——加固原理