Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a dotted circle in Android View [closed]

Tags:

android

I need to display a dotted circle within a view.

like image 886
sek Avatar asked Dec 10 '10 06:12

sek


1 Answers

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();
    }
}
like image 70
U.P Avatar answered Oct 09 '22 23:10

U.P