今天在学习android开发的时候,写了这样的一段代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<ImageView
android:id="@+id/imageview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
/>
</LinearLayout>

然后eclipse就报出提示:This tag and its children can be replaced by one <TextView/> and a compound drawable

最后查了一下资料发现:

有时候我们可能会用image+textview组合,但其实image是没必要的,textview提供了一个属性来给它设置image

如:通过 setCompoundDrawable 方法, 或者直接在xml中使用android:drawableLeft.、android:drawableRight等属性指定!

其他:

  • Set android:baselineAligned="false" on this element for better performance

    • 如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算
    • android:baselineAligned="false"
  • This LinearLayout layout or its RelativeLayout parent is useless;
    • 多余的Linearlayout或者RelativeLayout
    • 删除即可
  • Use a layout_height of 0dip instead of wrap_content for better   performance
    • 当在一个linearlayout布局中为一个控件设置weight属性时,这个组件会默认填充剩余空间
    • 去掉weight属性或者修改wrap_content为0dp
  • Buttons in button bars should be borderless
    • 原因未知
    • style="?android:attr/buttonBarButtonStyle"

资料摘自:http://www.tuicool.com/articles/YvMjEz  

      http://blog.csdn.net/feng88724/article/details/7638511

eclipse提示:This tag and its children can be replaced by one <TextView/> and a compound drawable的更多相关文章

  1. This tag and its children can be replaced by one <TextView/> and a compound drawable

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  2. android xml文件中出现如下提醒:This tag and its children can be replaced by one <TextView/> and a compound drawable

    第一个感叹号 是跟你说 让你把Imageview 和textview 结合起来 只用 textview textview有个属性叫  android:drawable...(top/bottom/.. ...

  3. Eclipse提示Tomcat miss丢失bug:The Tomcat server configuration at \Servers\Tomcat v5.5 Server at localhost-config is missing.

    Eclipse提示Tomcat miss丢失bug:The Tomcat server configuration at \Servers\Tomcat v5.5 Server at localhos ...

  4. java工程项目里,在一个包里面,不能出现同名的类名,这问题是刚接触java才会遇到的,特别是新手一般都没有建立包,而是使用默认的,易出现同名的类名,导致eclipse提示错误

    java工程项目里,在一个包里面,不能出现同名的类名,这问题是刚接触java才会遇到的,特别是新手一般都没有建立包,而是使用默认的,易出现同名的类名,导致eclipse提示错误. 问题: 创建了一个工 ...

  5. Ubuntu12.04下eclipse提示框黑色背景色的修改方法

    eclipse提示框的背景颜色使用的是系统的提示框颜色配置,在windows下为黄色,但在Ubuntu12.04(gnome)下却是黑色,造成提示内容很难看清. 在eclipse中我们是无法修改这个颜 ...

  6. 导入Maven项目后,Eclipse提示“Missing artifact ”类的错误

    导入Maven项目后,Eclipse提示“Missing artifact ”类的错误 标签: Maven Missing art 2016-08-15 16:05 679人阅读 评论(0) 收藏 举 ...

  7. Ubuntu——修正LibreOffice中文乱码以及eclipse提示框颜色

    刚进ubuntu的时候就老遇到用libreoffice打开某些文档时出现一堆叠在一起的乱码.以及最開始使用eclipse编辑时,鼠标放到一个变量或者函数时 弹出来一黑框框-看的难受的.... 这里记录 ...

  8. [转载]Eclipse提示No java virtual machine

    第一次运行Eclipse,经常会提示下面的问题:... No java virtual machine  was found after searching the follwing location ...

  9. Ubuntu 14.04 eclipse 提示框背景色更改

    首先查看系统设置->外观->主题. 不同的主题需要更改的文件不同 sudo vim /usr/share/themes/主题(就是刚才主题的名字,ubuntu14.04默认是Ambianc ...

随机推荐

  1. 浏览器端获取局域网IP地址,本机的MAC,以及机器名

    原文链接:http://www.orlion.ga/59/ 只针对IE且客户端的IE允许AcitiveX运行 code: <html> <head> <title> ...

  2. CSS三列布局

    × 目录 两侧定宽中间自适应 两列定宽一侧自适应 中间定宽两侧自适应一侧定宽两列自适应三列自适应总结 前面的话 前面已经介绍过单列定宽单列自适应和两列自适应的两列布局.本文介绍三列布局,分为两侧定宽中 ...

  3. javase基础复习攻略《八》

    进入第八篇,我们开始讨论JAVA的IO初步.在JAVA程序中,对数据的输入\输出操作以"流"(stream)方式进行,J2SDK提供了各种各样的"流"类,用于获 ...

  4. 序列sequence中的cache问题

    Oracle中序列Sequence的创建语法如下: CREATE SEQUENCE [ schema. ] sequence [ { INCREMENT BY | START WITH } integ ...

  5. Java多线程系列--“基础篇”07之 线程休眠

    概要 本章,会对Thread中sleep()方法进行介绍.涉及到的内容包括:1. sleep()介绍2. sleep()示例3. sleep() 与 wait()的比较 转载请注明出处:http:// ...

  6. [Matlab] tic toc

    tic Start a stopwatch timer.    tic and TOC functions work together to measure elapsed time.    tic, ...

  7. 对比MFC资源文件谈谈WPF布局方式

    对比MFC资源文件谈谈WPF布局方式 MFC方式 对于传统的MFC基于UI的应用程序设计通常分两步走,首先是设计UI,使用的是RC文件,然后是代码文件,对RC文件进行操作,如下面Figure 1 的基 ...

  8. [New Portal]Windows Azure Virtual Machine (11) 在本地使用Hyper-V制作虚拟机模板,并上传至Azure (1)

    <Windows Azure Platform 系列文章目录> 本章介绍的内容是将本地Hyper-V的VHD,上传到Azure数据中心,作为自定义的虚拟机模板. 注意:因为在制作VHD的最 ...

  9. dom4j的读写xml文件,读写xml字符串

    百度了一些博客,大同小异,在选取jar包工具的时候大概看了下,大抵是jdom原始,dom4j优秀.于是做了些练习. 参考:http://www.cnblogs.com/mengdd/archive/2 ...

  10. 选择排序---直接选择排序算法(Javascript版)

    在要排序的一组数列中,选出最小(或者最大)的一个数与第1个位置的数交换:然后在剩下的数当中再找最小(或者最大)的与第2个位置的数交换,依次类推,直到第n-1个元素(倒数第二个数)和第n个元素(最后一个 ...