Change drawable color programmatically
Solution 1:
Try this:
Drawable unwrappedDrawable = AppCompatResources.getDrawable(context, R.drawable.my_drawable);
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, Color.RED);
Using DrawableCompat
is important because it provides backwards compatibility and bug fixes on API 22 devices and earlier.
Solution 2:
You can try this for svg vector drawable
DrawableCompat.setTint(
DrawableCompat.wrap(myImageView.getDrawable()),
ContextCompat.getColor(context, R.color.another_nice_color)
);