Show Circle Image in Android
Here I will show you how to draw a bitmap within a circle, instead of a block.
Just override your onDraw method and use this sample:
// init shader
BitmapShader shader;
shader = new BitmapShader(originalBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
// init paint
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
int circleCenter = width / 2;
// circleCenter is the x or y of the view's center
// radius is the radius in pixels of the cirle to be drawn
// paint contains the shader that will texture the shape
canvas.drawCircle(circleCenter, circleCenter, radus, paint);
Source (my blog): http://nadavfima.com/circle-image/
Written by Nadav Fima
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Imageview
Authors
nadavfima
5.329K
frapontillo
1.694K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#