I want to edit the fill Color of a vector-file in Android programmatically.
In the xml-file I can set my color with the attribute android:fillColor
None of these answers worked for changing the color of a vector path inside a drawable at runtime. In fact, I still didn't figure that out, but I think this answer would help a lot of people who are just trying to create and paint a simple shape at runtime.
I was trying to create a custom border Mvvm binding to customise the border & fill colors of a Button at runtime. For a while I was trying to modify an Android drawable to achieve this but found out that wasn't possible. Eventually I figured out how to do this with GradientDrawable.
I'm using Xamarin.Android in C# so it does look slightly different from Java.
GradientDrawable gd = new GradientDrawable();
gd.SetColor(Color.Red);
gd.SetCornerRadius(10);
gd.SetStroke(3, Color.White);
view.Background = gd;