Android的画圆用不同颜色的边框边框、不同颜色、Android、画圆用

2023-09-07 15:27:29 作者:陪你一辈子

是否有可能只用一个画圆法画在画布上一个圆圈在android系统用不同颜色的边框?

Is it possible to draw a circle on a canvas in android with a different colour border using only one drawCircle method?

我已经注意到FILL_AND_STROKE的PaintStyle,但不能似乎有不同的颜色填充和边框都。

I have noticed the PaintStyle of FILL_AND_STROKE but cant seem to have different colours for both the fill and the border.

我真的不希望有调用两个画圆的方法。

I really don't want to have to call two drawCircle methods.

感谢

推荐答案

Paint.Style的定义说:

Definition of Paint.Style says:

Paint.Style The Style specifies if the primitive being drawn is filled, 
stroked, or both (in the same color). 

所以看起来它不能在一气呵成完成。

So it seems it can't be done in one go.

如果你这样做了很多,你可以创建一个具有两个电话绘制镶上一圈静态辅助方法。

If you do this a lot you can create a static helper method that does two calls to draw bordered circle.

或者你可以创建一个自定义android.graphics.drawable.shapes.Shape对象,并重写它的Draw(..)方法。 http://developer.android.com/reference/android/graphics/drawable/shapes/Shape.html

Or you could create a custom android.graphics.drawable.shapes.Shape object and override it's draw(..) method. http://developer.android.com/reference/android/graphics/drawable/shapes/Shape.html

 
精彩推荐