设置油漆
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(30);
mPaint.setPathEffect(new DashPathEffect(new float[]{1, 60}, 0f));
mPaint.setStrokeCap(Paint.Cap.ROUND);
使用示例
canvas.drawPath(mPath, mPaint);
更新
还有另一种方法。在这里你可以设置任何形状
paintBlue = new Paint(Paint.ANTI_ALIAS_FLAG);
float mRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, context.getResources().getDisplayMetrics());
paintBlue.setStyle(Paint.Style.STROKE);
paintBlue.setAntiAlias(true);
paintBlue.setColor(Color.BLACK);
paintBlue.setStrokeWidth(12);
Path shapePath = new Path();
shapePath.addCircle(0, 0, mRadius, Path.Direction.CCW);
PathDashPathEffect pathDashPathEffect = new PathDashPathEffect(shapePath, mRadius * 4, 0, PathDashPathEffect.Style.ROTATE);
paintBlue.setPathEffect(pathDashPathEffect);