Use a layout_width of 0dip instead of fill_parent for better performance
来源:互联网 发布:淘宝直播主播培训 编辑:程序博客网 时间:2024/05/17 21:45
安装了最新的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就相当于初始化时不需要绘制了!
- Use a layout_width of 0dip instead of fill_parent for better performance
- Use a layout_width of 0dip instead of fill_parent for better performance
- Use a layout_width of 0dip instead of fill_parent for better performance
- Use a layout_height of 0dip instead of 700dp for better performance
- Use layout_height of 0dip instead of wrap_content for better Performance
- Use a layout_height of 0dp instead of match_parent for better performance问题说明
- Why Use Git Instead of a Legacy Version Control System
- use supervisor instead of nohup
- How to use SQL store procedure to trace SQL performance instead of SQL profiler
- Use '$' instead of '.' for inner classes (or use only lowercase letters in package names)
- Use '$' instead of '.' for inner classes (or use only lowercase letters in package names) 问题
- use sys_guid() to instead of sequence
- When to Use Delegates Instead of Interfaces
- Effective Objective-C 2.0:Item 50: Use NSCache Instead of NSDictionary for Caches
- 5 Reasons to Use Protocol Buffers Instead of JSON For Your Next Service
- 关于AndroidManifest.xml报Use ' instead of '.' for inner classes....警报的解决办法
- Why don't we use a constructor instead of factory method?
- 干活来袭:Effective Concurrency: Know When to Use an Active Object Instead of a Mutex
- ORACLE 分页SQL
- Android中Shape的了解
- Request对象的主要方法
- 复制中慎用*_do_db和*_ignore_db过滤选项
- 技术人员谈管理之质量管理案例论文
- Use a layout_width of 0dip instead of fill_parent for better performance
- @Resource注解
- 复制监控中的Seconds_behind_master并不可信
- 让RichTextBox或TextBox自动滚动,始终显示最新的内容
- 开源巨人火狐浏览器:9周岁生日快乐!
- Eclipse上安装GIT插件EGit及使用
- 百万用户时尚分享网站feed系统扩展实践
- 堆排序算法
- HTML5 classList 小结