android set background color programmatically code example
Example 1: android settextcolor programmatically
mTextView.setTextColor(Color.parseColor("#bdbdbd"));
Example 2: how to change background tint color programmatically android
Drawable buttonDrawable = button.getBackground();
buttonDrawable = DrawableCompat.wrap(buttonDrawable);
//the color is a direct color int and not a color resource
DrawableCompat.setTint(buttonDrawable, Color.RED);
button.setBackground(buttonDrawable);