我有TextView
并且我想以编程方式绘制圆角矩形,我想将该形状设置为TextView
的背景?我想动态地改变它的颜色,我已经张贴了这张照片?
答案 0 :(得分:4)
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);
}
此处查看v =您的textview或按钮或任何内容。