根据不同场景设置不同的背景颜色:

//动态设置TextView的背景颜色
GradientDrawable drawable = new GradientDrawable();
drawable.setCornerRadius(5);
drawable.setStroke(1, Color.parseColor("#FF000000"));
drawable.setColor(Color.parseColor("#FF000000"));
tv_type.setBackgroundDrawable(drawable);