简体   繁体   English

Android在运行时将Stroke添加到Drawable

[英]Android add Stroke to Drawable on Runtime

I found this function. 我发现了这个功能。 How can I now add a Stroke to my Drawable? 现在如何向我的可绘制对象添加笔触?
There is nothing like setStroke(...) 没有什么像setStroke(...)

Try creating a paint variable with the your intended color/stroke width/ (also set style=stroke) and then use it in the onDraw method: 尝试使用所需的颜色/笔划宽度/(还设置style = stroke)创建一个绘画变量,然后在onDraw方法中使用它:

onDraw(Shape shape, Canvas canvas, Paint paint)

In this way, the stroke will be added when you draw. 这样,在绘制时将添加笔触。 It will not be attached to your Drawable. 它不会附加到您的Drawable。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM