I have a Drawable inside an image view that I'm modifying at runtime in order to provide custom colors for a user's rank. The method for modifying this works fine on Android versions below 20, but above it the drawable fails to update consistently.
The particular method in question looks like:
void setColor(int color) {
GradientDrawable drawable = (GradientDrawable) mImageView.getDrawable().mutate();
drawable.setStroke(14, color);
drawable.invalidateSelf(); // make sure we redraw
}
As I said, this works fine before Android 20, but after Android 20 the drawable doesn't add the stroke. Is there a new method or did I forget something?
you should invalidate the view:
mImageView.invalidate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With