安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_new); //调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示 rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); // left, top, right, bottom tvVersionStatus.setCompoundDrawables(null, null, rightDrawable, null); // left, top, right, bottom
https://blog.csdn.net/catoop/article/details/39959175
<TextView android:id="@+id/tv_versionstatus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawablePadding="5dp" android:drawableRight="@drawable/icon_new" android:text="版本" android:textColor="#363636" android:textSize="20sp" />