Android(安卓)开发 Tip 15 -- can be replaced by one and a compound drawable
16lz
2021-01-26
转载请注明出处:http://blog.csdn.net/crazy1235/article/details/72526781
This tag and its children can be replaced by one and a compound drawable
当xml布局文件中,出现两个紧挨着的
意思就是可以通过一个
比如:
<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>
可以替换成:
"@drawable/icon_add" android drawablePadding="5dp" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/app_name"/>
减少布局层级,减少测量布局绘制的耗时~
更多相关文章
- Android(安卓)TabLayout简单使用
- Android(安卓)LayoutInflater.inflate()方法参数详解
- Android(安卓)RecyclerView使用(一) 基本使用
- Android入门:搭建环境、工程目录剖析、Activity生命周期
- Android布局_LinearLayout布局
- [Android]Fragment的应用/点击替换fragment应用实例
- android Intent和菜单的使用
- 给其他布局文件的控件添加监听事件
- Android---添加结构线或边框的几种方式