Invisible SurfaceView for Camera Preview

我的未来我决定 提交于 2019-11-29 07:06:05

i also used the same stackOverflow answer, and get the same problem.so:

i've added this code

this.setZOrderOnTop(true);
SurfaceHolder h = this.getHolder();
h.setFormat(PixelFormat.TRANSPARENT);

to my surfaceChanged method, instead of the activity (or a service at my case), and got it trasparent, but the Log complains on abandoned frames :(

You don't actually have to place the SurfaceView on your UI at all. We were running into the same issue and made a dummy SurfaceView. Here's our code:

SurfaceView dummy = new SurfaceView(c);
try {
    mCamera.setPreviewDisplay(dummy.getHolder());
} catch (IOException e) {

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