Reputation: 1252
I have TextView
and I want to draw Rounded Rectangle shape programmatically and I want to set that shape as a Background of TextView
? and I want to change it colors dynamically, I have posted the picture ?
Upvotes: 2
Views: 5598
Reputation: 35589
public static void makeRoundCorner(int bgcolor,int radius,View v,int strokeWidth,int strokeColor)
{
GradientDrawable gdDefault = new GradientDrawable();
gdDefault.setColor(bgcolor);
gdDefault.setCornerRadius(radius);
gdDefault.setStroke(strokeWidth, strokeColor);
v.setBackgroundDrawable(gdDefault);
}
here View v = your textview or button or anything.
Upvotes: 6