java - Draw on transparent SurfaceView -
i have following problem: made class extends surfaceview, implements surfaceholder.callback when try draw red square, it's black. below code:
first call following method in constructor:
private void inittransparentbackgroundcolor(){ this.setbackgroundcolor(color.transparent); this.setzorderontop(true); getholder().setformat(pixelformat.transparent); }
then, start drawing:
protected void ondraw(canvas canvas){ paint p = new paint(); p.setcolor(color.red); p.setstyle(paint.style.fill_and_stroke); canvas.drawrect(10,10,20,20,p); }
what doing wrong?
replace
getholder().setformat(pixelformat.transparent);
to this
getholder().setformat(pixelformat.translucent);
good luck. :)
Comments
Post a Comment