http://stackoverflow.com/questions/2933882/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 orRelativeLayout, but have it appear after the SurfaceView

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

See here for a sample project that layers popup panels above a SurfaceView used for video playback.

 

FrameLayout的特殊之处:

Children are drawn in a stack, with the most recently added child on top.

虽然有如上的可以draw overlay的方法,但如果overlay是个GlSurfaceView,问题就来了。请看:

http://groups.google.com/group/android-developers/browse_thread/thread/ea95e80aeaa1a196?pli=1

http://stackoverflow.com/questions/3304689/android-camera-preview-question,至今无解。

 

附注:

  1. 一篇不错的关于如何使用android camera的文章,http://www.ophonesdn.com/article/show/144
  2. 一个不错的camera usage问题
    http://stackoverflow.com/questions/2734886/droids-mediaserver-dies-on-camera-takepicture
  3. http://nhenze.net/?tag=opengl   这里是draw a GLSurfaceView on CameraPreview的 answer
Advertisements