Android 开发 Tip 15 -- can be replaced by one <TextView/> and a compound drawable
来源:互联网 发布:win10怎么连网络打印机 编辑:程序博客网 时间:2024/06/08 08:59
转载请注明出处:http://blog.csdn.net/crazy1235/article/details/72526781
This tag and its children can be replaced by one <TextView/> and a compound drawable
当xml布局文件中,出现两个紧挨着的 <ImageView /> <TextView />,IDE就会给出这样一个提示!
意思就是可以通过一个 <TextView /> 控件,然后设置 compound drawable 属性来替代完成!
比如:
<LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content"> <ImageView android:src="@drawable/icon_add" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/app_name"/> </LinearLayout>
可以替换成:
<TextView android:drawableLeft="@drawable/icon_add" android drawablePadding="5dp" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/app_name"/>
减少布局层级,减少测量布局绘制的耗时~
阅读全文
0 0
- Android 开发 Tip 15 -- can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- android This tag and its children can be replaced by one <TextView/> and a compound drawable 布局文件提示
- 【Android学习笔记】This tag and its children can be replaced by one <TextView/> and a compound drawable
- eclipse提示:This tag and its children can be replaced by one <TextView/> and a compound drawable
- 关于 This tag and its children can be replaced by one <TextView/> and a compound drawable 的问题
- This tag and its children can be replaced
- Android 开发 Tip 12 -- 各种Drawable
- 1075 - Incorrect table definition;there can be only one auto column and it must be defined as a key
- Incorrect table definition; there can be only one auto column and it must be defined as a key
- MySQL 数据表创建报错:there can be only one auto column and it must be defined as a key
- 1075-Incorrect table definition;there can be only one auto column and it must be defined as a key
- A Docking control that can be dragged and resized by the user
- maven jetty 热部署 Files are locked on Windows and can't be replaced
- Centos 7.0下samba笔记
- GET请求
- iOS UIAlertController
- 数据结构之数组
- qudoj Xor 思维
- Android 开发 Tip 15 -- can be replaced by one <TextView/> and a compound drawable
- GOLANG使用嵌入结构实现接口
- c++实验6-项目3
- Android定制:去掉USB权限弹窗
- 【html】在消息按钮上增加数量角标
- Android动画(三)之属性动画(Property Animation)
- Pytorch入门——概述
- thinkpad S3笔记本无线网速慢的解决方案
- Why-How-What黄金圈法则 的理解和运用