Draw circle with different border colors Android -


public static bitmap drawcircle(int width,int height, int borderwidth) {     bitmap canvasbitmap = bitmap.createbitmap( width, height, bitmap.config.argb_8888);     bitmapshader shader = new bitmapshader(canvasbitmap, tilemode.clamp,                   tilemode.clamp);     paint paint = new paint();     paint.setantialias(true);     paint.setshader(shader);     paint.setshader(null);     paint.setstyle(paint.style.stroke);     paint.setcolor(color.white);     paint.setstrokewidth(borderwidth);       canvas canvas = new canvas(canvasbitmap);     float radius = width > height ? ((float) height) / 2f : ((float) width) / 2f;     canvas.drawcircle(width / 2, height / 2, radius - borderwidth / 2, paint);     return canvasbitmap; } 

simple code draws circle white border, want part of border black , other part white. 40 % of black, 60 % of white

how can done?

try code

class myview extends view {     private paint paint;      public myview(context context, int x, int y)     {         super(context);         paint = new paint();         // porterduffxfermode xfermode = new porterduffxfermode(porterduff.mode.clear);          paint.setstyle(paint.style.stroke);         paint.setcolor(color.red);           paint.setalpha(255);         // paint.setxfermode(xfermode);         paint.setantialias(true);         // setbackgroundcolor(color.black);     }      @override     protected void ondraw(canvas canvas)     {         canvas.drawcircle(100, 100, 50, paint);     } } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -