Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SurfaceView overlay on camera view does not show when preview is on
    text
    copied!<p>I have a FrameLayout containing two SurfaceViews. One of them will show the camera preview, and the other is a custom surface view I use for drawing. Problem is the surface view does not show up. If I comment out the line where the camera starts preview, it does though, on the black background. This indicates me that the Surface view is positioned well, but I suspect that when the camera preview draws, something goes wrong.</p> <p>The camera view:</p> <pre><code>public CameraView(Context context, AttributeSet a) { super(context, a); mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } </code></pre> <p>The custom view:</p> <pre><code>public InclinaisonGauge(Context context, AttributeSet attrs) { super(context, attrs); getHolder().addCallback(this); getHolder().setFormat(PixelFormat.TRANSLUCENT); } @Override public void surfaceCreated(SurfaceHolder holder) { run = true; updateThread = new Thread() { public void run() { Canvas c = null; final SurfaceHolder inclHolder = getHolder(); while (run) { try { c = inclHolder.lockCanvas(); if(c!=null) { synchronized (inclHolder) { onDraw(c); } } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { inclHolder.unlockCanvasAndPost(c); } } } } }; </code></pre> <p>And I use this very simple draw method on the custom view to make sure it is not a framerate issue</p> <pre><code>public void doDraw(final Canvas canvas, final boolean bigSize, float daDirection) { canvas.drawARGB(255, 255, 255, 255); } </code></pre> <p>Has anyone experienced this?</p> <p>Thanks</p>
 

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