SurfaceView.setbackground() dominates my canvas

那年仲夏 提交于 2020-01-04 02:48:47

问题


When I set the background to my surfaceview, I see what I set as the background. However, I cannot draw simple things like circles when I lock/unlock the surfaceview's canvas. All I see is the background image.

Is there something I'm missing?

Any thoughts?


回答1:


You missed to google.

http://android-er.blogspot.com/2010/05/android-surfaceview.html

http://www.droidnova.com/playing-with-graphics-in-android-part-v,188.html




回答2:


The solution is very simple.

//get surface view and surface holder

mySurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceHolder = mySurfaceView.getHolder();

//place surface view holder on top of the surface view
mySurfaceView.setZOrderOnTop(true);

//set pixels of the surface holder to transparent to see the color of the
//surface view background

surfaceHolder.setFormat(PixelFormat.TRANSPARENT);


来源:https://stackoverflow.com/questions/3534452/surfaceview-setbackground-dominates-my-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!