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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -