Unable to draw on top of a custom SurfaceView class

烂漫一生 提交于 2019-12-02 03:49:18
gisking

This link might help: How to draw an overlay on a SurfaceView used by Camera on Android?

You just need to put your CameraPreview view into a FrameLayout, and have your DrawOnTop view at the same level as the FrameLayout, i.e.

FrameLayout frame = new FrameLayout(this);
addContentView(frame, new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
CameraPreview preview = new CameraPreview(this); 
frame.addView(mPreview);

DrawOnTop drawontop = new DrawOnTop(this);       
addContentView(drawontop, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
drawontop.setVisibility(View.VISIBLE);
drawontop.bringToFront();

Does that work for you?

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