I have a vector drawable, which is inside of imageview in layout. I would like to set gradient color programmatically (depending on some cases). I'm able to set a specific color to the imageview by using ColorFilter. How can I also set a gradient to a vector drawable?
Asked
Active
Viewed 475 times
1
-
1Please first clear your answer and add some explanation – Shoaib Kakal May 07 '20 at 15:41
-
1What kind of explanation do you want? I have an imageview with vector inside. I'm able to change the vector's figure color programmatically, but how can I set gradient color for it? I need to set a gradient color for the vector figure (not background). For example, I use this to change the color of the figure. imageView.setColorFilter(Color.RED); But it's only for a single monochromatic color. I would like to apply a gradient. – Anar May 07 '20 at 15:55
-
no way, just create a set of VectorDrawables – Style-7 May 07 '20 at 17:37
-
Duplicates https://stackoverflow.com/questions/23991395/add-gradient-to-imageview ? – David Bodow May 07 '20 at 21:50
-
I don't think so. I need to change it programmatically, not in the XML. Is there no way to change it in code? I want to make smooth gradient animation for vector drawable. – Anar May 08 '20 at 09:23