塗料の設定
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);