5

hi everybody I have a custom view that in it I use clippath for clip a circle this is my code

Bitmap bitmap=Bitmap.createBitmap(min,min,Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
Paint paint = new Paint();
paint.setStrokeWidth(2);
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
Path path2=new Path();
path2.addCircle(x0, y0,r2,Path.Direction.CCW);
c.clipPath(path2,Region.Op.DIFFERENCE);
paint.setColor(0xFF09103e);
c.drawCircle(x0,y0,r1,paint);

my problem is that when i draw my circle it isnt smooth in edges of its inside where it cliped by other circle.

  • use `Paint.setFlags(Paint.ANTI_ALIAS_FLAG)`; to draw the smooth edge see if this solve the issue ...... – BBdev Oct 08 '13 at 07:20
  • it dont work.I set setFlags(Paint.ANTI_ALIAS_FLAG) and paint.setAntiAlias(true); but it dont work still @BBdev –  Oct 08 '13 at 07:33

1 Answers1

3

I find my answer.I cant smooth path cliped by setFlags(Paint.ANTI_ALIAS_FLAG) or paint.setAntiAlias(true); but i can try to draw the path on top of the bitmap as a blurred transparent with paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); (or was it DST_OUT?)

  • 1
    check this answer for full picture http://stackoverflow.com/questions/16208365/create-a-circular-image-view-in-android – Rafael Mar 05 '15 at 04:43