/**
* 设置TextView右侧图标
*
* @param textView
*/
public static void setTextViewRightDrawable(TextView textView, int icon) {
Drawable drawable = textView.getContext().getResources().getDrawable(icon);// 获取res下的图片drawable
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());// 一定要设置setBounds();
textView.setCompoundDrawables(null, null, drawable, null);
}
使用如下:
int strokeWidth = 1; // 1dp 边框宽度
int roundRadius = 10; // 5dp 圆角半径
int fillColor = mContext.getResources().getColor(R.color.golden_yellow); //内部填充颜色
int strokeColor = Color.parseColor("#ffffff");//边框颜色
BtnUtils.setViewShapeColor(holder.tv, fillColor, strokeColor, strokeWidth, roundRadius);