标签:
今天在学习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等属性指定!
其他:
资料摘自: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
标签:
原文地址:http://www.cnblogs.com/JamKong/p/5043554.html