动态添加图片到textview周围
Drawable img = context.getResources().getDrawable(R.drawable.car_value_goto_bg);
// 调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示
img.setBounds(0, 0, img.getMinimumWidth(), img.getMinimumHeight());
stepsTv.setCompoundDrawables(null, null, img, null); // 设置右图标
如果在xml文件中可以直接android:drawableRight="@drawable/car_value_goto_bg"
由于Android机制问题,不建议深嵌套,尽量减少LinearLayout的使用,动态添加图片不失为一种好办法。