是否有可能仅使用一个drawCircle方法绘制在Android的画布上的圆用不同的颜色边界?

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

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

有帮助吗?

解决方案

Paint.Style的定义表示:

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

因此,似乎不能一次过完成。

如果你这样做了很多,你可以创建一个具有两个电话绘制边框圆一个静态的helper方法。

或者你可以创建一个自定义 android.graphics.drawable .shapes.Shape 对象并覆盖其拉伸(..)方法。

其他提示

感谢彼得Knego!

如果万一任一需要的形状这里XML的是

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
 android:shape="oval">
    <solid android:color="#FFFFFF"/>
    <stroke android:width="5dp" android:color="#FFFF00" />
    <size
        android:width="50dp"
        android:height="50dp" />

    <corners android:radius="20dp" />
</shape> 

尝试使一个类并且通过使小于另一个两个一创建与边界圆然后使用类作为你的形状,而不是预定义的形状

可以画一个圆与Style.STROKE一个层上的其他的圆。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top