转载请注明出处:http://blog.csdn.net/crazy1235/article/details/72526781


 This tag and its children can be replaced by one  and a compound drawable

当xml布局文件中,出现两个紧挨着的 ,IDE就会给出这样一个提示!

意思就是可以通过一个 控件,然后设置 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>  

可以替换成:

    "@drawable/icon_add"        android drawablePadding="5dp"        android:layout_height="wrap_content"          android:layout_width="wrap_content"          android:text="@string/app_name"/>  

减少布局层级,减少测量布局绘制的耗时~

更多相关文章

  1. Android(安卓)TabLayout简单使用
  2. Android(安卓)LayoutInflater.inflate()方法参数详解
  3. Android(安卓)RecyclerView使用(一) 基本使用
  4. Android入门:搭建环境、工程目录剖析、Activity生命周期
  5. Android布局_LinearLayout布局
  6. [Android]Fragment的应用/点击替换fragment应用实例
  7. android Intent和菜单的使用
  8. 给其他布局文件的控件添加监听事件
  9. Android---添加结构线或边框的几种方式

随机推荐

  1. 如果Imageview与Linearlayout有叠加且可
  2. Android的SDK与ADT不匹配问题
  3. android studio 报Error:failed to find
  4. 环境变量ANDROID_SDK_HOME的作用
  5. android控件之ImageButton android:scale
  6. android布局居中
  7. android:各种访问权限Permission
  8. android消息处理机制学习(一)-Handler,Mess
  9. android 二 BMI 小例子
  10. Android 3.0 r1 API中文文档(107) —— A