zl程序教程

您现在的位置是:首页 >  其它

当前栏目

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

and gt by be lt this can One
2023-09-11 14:18:01 时间

写了这么一段代码:

  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等属性指定!