Search code examples
androidpaintandroid-progressbarstroke

How to give border to circle using paint


Hi i have implemented Progress bar and it is working fine, but my problem is i need to give a only border to circle using paint. I worked on that but it is taking all the area of circle, i need only border.

My paint code:

    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.MITER);
    // mCirclePaint.setShadowLayer(4.0f, 0.0f, 2.0f, Color.BLACK);
    mCirclePaint.setStrokeCap(Paint.Cap.SQUARE);
    canvas.drawPath(mCirclePath, mCirclePaint)

Solution

  • try this ,

    paint = new Paint();
    paint.setColor(Color.GREEN);        
    paint.setStrokeWidth(2);            
    paint.setStyle(Paint.Style.STROKE);         
    canvas.drawCircle(0, 0, (float) (width1/(1.4)), paint); 
    

    and refer this , might be help full to you .Android : canvas.drawBitmap() method not working properly