11

I need to display a dotted circle within a view.

OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
sek
  • 193
  • 1
  • 1
  • 9

1 Answers1

18

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();
    }
}
Gary Chen
  • 238
  • 2
  • 14
U.P
  • 7,274
  • 6
  • 36
  • 60