public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
- oval :指定圆弧的外轮廓矩形区域。
- startAngle: 圆弧起始角度,单位为度。
- sweepAngle: 圆弧扫过的角度,顺时针方向,单位为度,从右中间开始为零度。
- useCenter: 如果为True时,在绘制圆弧时将圆心包括在内,通常用来绘制扇形。关键是这个变量,下面将会详细介绍。
- paint: 绘制圆弧的画板属性,如颜色,是否填充等。
Paint paint = new Paint();
paint.setStrokeWidth(20);
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.BLUE);
float startAngle01 = 3;
float sweepAngle01 = 86;
RectF rect = new RectF(center - radius, center - radius, center
+ radius, center + radius);
canvas.drawArc(rect, startAngle01, sweepAngle01, true, paint);
paint.setStrokeWidth(20);
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.BLUE);
float startAngle01 = 3;
float sweepAngle01 = 86;
RectF rect = new RectF(center - radius, center - radius, center
+ radius, center + radius);
canvas.drawArc(rect, startAngle01, sweepAngle01, true, paint);
当第4个参数为true的绘图如下
当是false的情况时,效果图如下
这个参数为true时,会从圆弧的起始点到终点画两条边框