An easy way to achieve this effect is to use Canvas.drawCircle() and BitmapShader :
BitmapShader s = new BitmapShader(myPhoto, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); Paint p = new Paint(); p.setShader(s); myCanvas.drawCircle(centerX, centerY, radius, p);
To make a shadow, simply draw Paint.setShadowLayer() on the paint (this will work only if you draw the effect on an off-screen Bitmap or if your View uses a program level - set when calling View.setLayerType() -).
You can draw a border by drawing another circle on top using the Paint.Style.STROKE style (which you can set by calling Paint.setStyle() ).
Finally, you can draw a sparkle by drawing a circle, oval, or Path on top of your very first circle. You will need the LinearGradient shader on your paint, and you will also need to fix the shine. You can do this in two ways:
- If you paint the whole effect in
Bitmap , which I would recommend, just set the Xfermode paint to new PorterDuffXfermode(PorterDuff.Mode.SRC_IN) . - If you draw an effect directly on the screen, you can simply use
Canvas.clipPath() to set the circular clip. Please note that this will only work with hardware acceleration with Android 4.3.
source share