Android – How to create invisible camera preview for video recording?-Collection of common programming errors

I want to create hidden SurfaceView for camera preview. I tried method recommended in answer to another question:

WindowManager wm = (WindowManager) mCtx.getSystemService(Context.WINDOW_SERVICE);
params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
        PixelFormat.TRANSLUCENT);        
wm.addView(surfaceview, params);

surfaceview.setZOrderOnTop(true);
mHolder.setFormat(PixelFormat.TRANSPARENT);

but it isn’t invisible, in fact it takes the whole screen. I tried setting alpha or resizing it but it doesn’t work. Is there a way to making it hidden or at least resizing it to 1×1 size?

EDIT:

I would also add that simply placing 1×1 SurfaceView in activity layout wouldn’t work in my case because I use multiple layouts and I believe Views are destroyed on layout change…