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 @   brave-sailor  阅读(1115)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示