[英]Android how to draw Rounded Rectangle shape programmatically
我有TextView
,我想以編程方式繪制Rounded Rectangle形狀,並將該形狀設置為TextView
的背景嗎? 我想動態更改它的顏色,我已經貼了圖片嗎?
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或按鈕或其他任何內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.