android - Fill layout with color with exception of some child view -
i want show overlay on layout, overlay has translucent color fills view exception. these exception shape transparent color highlight background view overlay covering.
my question how set translucent color fill parent view color exception area inside parent view.
answer use "canvas.clippath()", here example code
public class circularclipview implements view { final path path = new path(); public circularclipview(final context context, final attributeset attrs, final int defstyleattr) { super(context, attrs, defstyleattr); } @override protected void ondraw(final canvas canvas) { super.ondraw(canvas); canvas.save(); final int viewwidthhalf = 300; final int viewheighthalf = 300; final int radius = 100; path.addcircle(viewwidthhalf, viewheighthalf, radius, path.direction.cw); canvas.clippath(path, region.op.difference); canvas.drawcolor(r.color.transparen); //#c5000000 canvas.restore(); } }
Comments
Post a Comment