I need to display a dotted circle within a view.
Asked
Active
Viewed 1.1k times
1 Answers
17
Try this solution:
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();
}
}
-
9Creating a new Paint and calling invalidate() in each onDraw call is a bad idea! – LukaCiko Jan 19 '15 at 14:12
-
what if i want dotted circle around circular button? – Feroz Siddiqui Apr 16 '21 at 19:03