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

写了这么一段代码:

  1.    <LinearLayout   
  2.        android:orientation="horizontal"  
  3.        android:layout_centerInParent="true"  
  4.     android:layout_height="wrap_content"  
  5.     android:layout_width="wrap_content">  
  6.     <ImageView   
  7.         android:id="@+id/grid_icon"  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content"/>  
  10.     <TextView  
  11.         android:id="@+id/grid_text"  
  12.         android:layout_height="wrap_content"  
  13.         android:layout_width="wrap_content"  
  14.         android:text="@string/app_name"/>  
  15. </LinearLayout>  


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

 

最后发现原来可以直接给TextView加图片.. ,通过 setCompoundDrawable 方法, 或者直接在xml中使用android:drawableLeft.、android:drawableRight等属性指定!

 

 

posted @ 2013-10-28 10:36  brave-sailor  阅读(1114)  评论(0编辑  收藏  举报