Draw a circle within circle at a distance of 10

前端 未结 1 1358
萌比男神i
萌比男神i 2021-01-27 09:42

I have recently started working with Android, And I need to draw a Circle within Circle just like below image at a distance of 10. If you see the below photo, I need to draw som

1条回答
  •  攒了一身酷
    2021-01-27 10:11

    Try:

    protected void onDraw(Canvas canvas) {
                super.onDraw(canvas);
                Paint p = new Paint();
                p.setColor(Color.RED);
                DashPathEffect dashPath = new DashPathEffect(new float[]{5,5}, (float)1.0);
    
                p.setPathEffect(dashPath);
                p.setStyle(Style.STROKE);
    
    
                for (int i = 0; i < 7; i ++) {
                    canvas.drawCircle(100, 100, 50+(i*10), p);
                }
    
    
                invalidate();
            }
    

    0 讨论(0)
提交回复
热议问题