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

今天在学习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

转载于:https://www.cnblogs.com/JamKong/p/5043554.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值