Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have had success with the following approach.</p> <p>First make a layout xml file that looks something like this (note the order of the two views):</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;com.yourcustom.OverlayView android:id="@+id/overlay" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/com.yourcustom.OverlayView&gt; &lt;SurfaceView android:id="@+id/surface" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/SurfaceView&gt; &lt;/FrameLayout&gt; </code></pre> <p><code>OverlayView</code> is a subclass of <code>SurfaceView</code> with the drawing and animation thread implementations. The other SurfaceView will be the surface that handles the Camera preview. Inside of <code>onCreate</code> you should set up your views like this:</p> <pre><code> mView = (OverlayView)this.findViewById(R.id.overlay); mView.getHolder().setFormat(PixelFormat.TRANSLUCENT); mSurfaceView = (SurfaceView)this.findViewById(R.id.surface); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); </code></pre> <p>You should add a <code>SurfaceHolder.Callback</code> implementation to the <code>SurfaceHolder</code> of <code>mView</code> that handles the animation thread. An example of implementing this within the subclass and using animation/drawing threads can be found in the old LunarLander example here: <a href="http://developer.android.com/resources/samples/LunarLander/src/com/example/android/lunarlander/LunarView.html" rel="nofollow noreferrer">http://developer.android.com/resources/samples/LunarLander/src/com/example/android/lunarlander/LunarView.html</a></p> <p>Besides that you set up the camera SurfaceView the same way as this example: <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html" rel="nofollow noreferrer">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload