Issue
I want to create a drawable that contains a circle with a background color that comes from an external file. As such I unfortunately can't simply load the drawable from an Xml file but have to create it dynamically in Java. How do I create my circle directly in Java?
Solution
I finally found a nonhacky way to create an oval shaped drawable:
GradientDrawable gd = new GradientDrawable();
int fillColor = Color.parseColor("FF0000");
gd.setColor(fillColor);
int strokeWidth = 2; // px not dp
int strokeColor = Color.parseColor("#000000");
gd.setStroke(strokeWidth, strokeColor);
gd.setShape(GradientDrawable.OVAL);
Answered By - Christian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.