How to draw circle with partitioned in android?

后端 未结 3 1027
温柔的废话
温柔的废话 2021-02-01 23:24

I want to draw this type of circle in my application. I am able to draw circle using Canvas but I can\'t get any idea about how to make partitioned?

Can anyone suggest m

3条回答
  •  失恋的感觉
    2021-02-01 23:55

    Hey I found the solution of my query,

    final RectF rect1 = new RectF();
    int mWidth = this.getWidth()/2;
    int mHeight = this.getHeight()/2;
    int mRadius = 130, mRadius1 = 50;
    rect1.set(mWidth -(mRadius-mRadius1), mHeight - (mRadius-mRadius1), mWidth + (mRadius-mRadius1), mHeight + (mRadius-mRadius1));
    
    Paint paintLines = new Paint();
    paintLines.setColor(Color.BLACK);
    paintLines.setStrokeWidth((mRadius-mRadius1)/2);
    paintLines.setAntiAlias(false);
    paintLines.setStrokeCap(Paint.Cap.BUTT);
    paintLines.setStyle(Paint.Style.STROKE);
    
    canvas.drawArc(rect1, 0, 1, false, paintLines); 
    canvas.drawArc(rect1, 30, 1, false, paintLines);
    canvas.drawArc(rect1, 60, 1, false, paintLines);
    canvas.drawArc(rect1, 90, 1, false, paintLines);
    canvas.drawArc(rect1, 120, 1, false, paintLines);
    canvas.drawArc(rect1, 150, 1, false, paintLines);
    

提交回复
热议问题