How to draw an overlay on a SurfaceView used by Camera on Android?

SurfaceView probably does not work like a regular View in this regard.

Instead, do the following:

  1. Put your SurfaceView inside of a
    FrameLayout or RelativeLayout in
    your layout XML file, since both of
    those allow stacking of widgets on
    the Z-axis
  2. Move your drawing logic
    into a separate custom View class
  3. Add an instance of the custom View
    class to the layout XML file as a
    child of the FrameLayout or
    RelativeLayout, but have it appear
    after the SurfaceView

This will cause your custom View class to appear to float above the SurfaceView.

Leave a Comment