sky*_*oot 11 android android-canvas
是否可以使用一种drawCircle方法在Android的画布上绘制一个具有不同颜色边框的圆圈?
我注意到了FILL_AND_STROKE的PaintStyle,但是填充和边框似乎都没有不同的颜色.
我真的不想要调用两个drawCircle方法.
Paint.Style的定义说:
Paint.Style The Style specifies if the primitive being drawn is filled,
stroked, or both (in the same color).
Run Code Online (Sandbox Code Playgroud)
所以它似乎无法一气呵成.
如果你这么做了很多,你可以创建一个静态辅助方法,它可以进行两次调用来绘制边界圆.
或者您可以创建自定义android.graphics.drawable.shapes.Shape对象并覆盖其draw(..)方法.
谢谢Peter Knego!
如果万一有需要Shape 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>
Run Code Online (Sandbox Code Playgroud)