[android] 表格布局和绝对布局
2023-02-18 15:49:56 时间
/*****************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来定位
相关文章
- 新东方推出线下自习室预约小程序,微搭低代码平台减少50%工作量
- 吐槽 Android的WebView的pauseTimers方法神坑 webview加载卡住
- 【开源库推荐】#1 SpiderMan 可快速查看Android闪退崩溃日志
- Android Studio 下载jcenter依赖失败问题及解决
- Android开发过程中的坑及解决方法收录(7)
- Android开发——RecyclerView实现下载列表
- Android开发——实现子线程更新UI
- 星之小说下载器Android版
- Android开发——Toolbar常用设置
- Android开发——Kotlin开发APP使用笔记
- Android开发模版代码(4)——状态栏设置
- 优化Recorder H5录音:可边录边转码上传服务器,支持微信提供Android IOS Hybrid App源码
- Android保存的文件显示到文件管理的最近文件和下载列表中
- HTML5网页录音和上传到服务器,支持PC、Android,支持IOS微信
- Hybrid小程序混合开发之路 - 数据交互
- html5录音支持pc和Android、ios部分浏览器,微信也是支持的,JavaScript getUserMedia
- Android Material Design控件使用(四)——下拉刷新 SwipeRefreshLayout
- Android Material Design控件使用(三)——CardView 卡片布局和SnackBar使用
- Taro小程序跨端开发入门实战
- Android开发过程中的坑及解决方法收录(六)