Camera preview UI overlay on Android?

混江龙づ霸主 提交于 2019-12-03 08:50:53

问题


How do I write code which layouts UI elements (Buttons, etc) over camera preview on Android ?


回答1:


Put the SurfaceView in a container that allows for Z-axis layering, such as RelativeLayout or FrameLayout. Put the things to appear on top of the SurfaceView later in the XML -- later children of a parent will draw over top of earlier children in the parent.

Here is a project using a SurfaceView for video playback that demonstrates the technique. The same concepts should hold for a SurfaceView for camera preview.

Bear in mind that extra work needs to be done by Android to blend your widgets with the preview, so your preview frame rate may drop.



来源:https://stackoverflow.com/questions/1966156/camera-preview-ui-overlay-on-android

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