Draw a circle within circle at a distance of 10

跟風遠走 提交于 2019-12-20 06:16:07

问题


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 something like below circle with two diameters like that and I don't need any icons that are there currently on the photo. Just a Circle within Circle having two diameters.

I want to draw only the circles and two diameter, not the icons on the circle. Any suggestions will be appreciated.

Update:-

I wrote the below code but it draws only one circle. I need to draw like the image above-

public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(demoview);
        }

        private class DemoView extends View{
            public DemoView(Context context){
                super(context);
            }

            @Override
            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);
                canvas.drawCircle(100, 100, 50, p);

                invalidate();
            }
        }
}

回答1:


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();
        }


来源:https://stackoverflow.com/questions/11549984/draw-a-circle-within-circle-at-a-distance-of-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!