问题
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