Android: looking for a drawArc() method with inner & outer radius

后端 未结 5 1676
逝去的感伤
逝去的感伤 2020-11-29 17:49

I have the following custom view:

\"alt

This I have achieved by using the Canvas\' drawArc

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 18:20

    drawing Circle and Arc. the following code is little dirty but it may help

            int sweepAngle sweepAngle = (360/7)%360;
        int startAngle = -90;
        int x = getWidth()/2;
        int y = getHeight()/2;
        int radius;
        radius = getWidth()/2-50;
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(50);
        paint.setColor(Color.WHITE);
    
        paint.setColor(Color.parseColor("#CD5C5C"));
        mBarPaintFill.setAntiAlias(true);
    
        canvas.drawCircle(x , y , radius, paint);
        paint.setColor(Color.BLUE);
        for (int i = 1 ; i<=5 ; i++){
    
            canvas.drawArc(x-radius,y-radius,x+radius,y+radius,startAngle,sweepAngle,false,paint);
            startAngle = (startAngle + sweepAngle+20)%360;
        }
    

提交回复
热议问题