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.

The camera view:

public CameraView(Context context, AttributeSet a) {
    super(context, a);
    mHolder = getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
The custom view:

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);
                }
            }
        }
    }
};
And I use this very simple draw method on the custom view to make sure
it is not a framerate issue

public void doDraw(final Canvas canvas, final boolean bigSize, float
daDirection)
{
    canvas.drawARGB(255, 255, 255, 255);
}
Has anyone experienced this?

Here is a simple eclipse project demonstrating the issue
http://dl.free.fr/f4rt18a1o

Start it and you will only see the camera. In CameraView, comment out
the line where it starts preview and you will see the SurfaceView
being drawn.

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to