How do I write code which layouts UI elements (Buttons, etc) over camera preview on Android ?
How do I write code which layouts UI elements (Buttons, etc) over camera preview on Android ?
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.