android控件TextView可以设置四周显示一个图片(drawable);
最简单的方法就是在XML里设置属性drawableLeft;
可以给EditText ,TextView四周设置图片
drawableTop,drawableBottom,drawableLeft,drawableRight
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/my_edittext_style"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:drawableLeft="@drawable/ic_launcher"
android:layout_marginTop="12dp"/>
但有时需求是要动态更换图片,可以参考下面的方法:
.setCompoundDrawables(left, top, right, bottom);