Use a layout_width of 0dip instead of fill_parent for better performance
for of use performance layout Parent width instead
2023-09-11 14:18:01 时间
安装了最新的ATD 18之后,新加的Lint Warnings插件会给我们检测出许多xml布局中不当的地方,例如:
Use a layout_width of 0dip instead of fill_parent for better performance
什么意思呢?举个简单的例子:
这是一个垂直布局,上下的线性布局各占高度50.0dp,中间的的TextView设置了android:layout_weight="1.0"属性,会将剩余空间填充满,这时候TextView的android:layout_width="fill_parent"就没有用了,应该改为android:layout_width="0.0dp"。
当设置了比重属性后,在这个方向上的长度就不确定了,不需要再去适配任何属性了,设置了也白设!因为控件都是绘制到屏幕上的,它会根据布局文件初始化控件在屏幕上的显示,所以设置0dip就相当于初始化时不需要绘制了!
相关文章
- Force Logout users if users are inactive for a certain period of time
- Is there a short-hand for nth root of x in Python 开n次方
- Docker For Windows | Setting Up Docker On Windows
- Aspose.Words for .NET使用章节教程(2):如何处理文档分段——Aspose.Words中的分段
- Aspose.Words for .NET使用文档教程(2):克隆文档
- Shell script for logging cpu and memory usage of a Linux process
- docker for windows--快速搭建各种关系型数据库RMDB的测试环境
- Failed to connect to apiserver: the server has asked for the clieto provide credentials
- 执行docker run命令时报错Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
- DISCOMAN: Dataset of Indoor SCenes for Odometry, Mapping and Navigation
- Input and Output-The input is all the sources of action for your app
- Mysql中use一个表出现警告:Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
- MAML —— Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks
- shell 脚本远程执行for循环的一些问题
- [LeetCode] 1286. Iterator for Combination 字母组合迭代器
- Watch out for these 10 common pitfalls of experienced Java developers & architects--转
- BEVDistill:Cross-Modal BEV Distillation for Multi-View 3D Object Detection——论文笔记
- 《CCNet:Criss-Cross Attention for Semantic Segmentation》论文笔记
- 《RVOS:End-to-End Recurrent Network for Video Object Segmentation》论文笔记
- 论文阅读笔记 PTI: Pivotal Tuning for Latent-based editing of Real Images
- 论文阅读笔记exploiting spatial dimensions of latenr in GAN for real-time image editing