Code example for SurfaceView

Methods: getHoldersetZOrderOnTop, setLayoutParams

0
        // underlying surface is created and destroyed. 
        mCameraHolder = mSurfaceView.getHolder();
        mCameraHolder.addCallback(this);
        //mCameraHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 
 
        mResultSurfaceView = new SurfaceView(context);
        lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
        mResultSurfaceView.setLayoutParams(lp);
        addView(mResultSurfaceView);
        mResultSurfaceView.setZOrderOnTop(true);
        // Install a SurfaceHolder.Callback so we get notified when the 
        // underlying surface is created and destroyed. 
        mResultHolder = mResultSurfaceView.getHolder();
        mResultHolder.setFormat(PixelFormat.TRANSPARENT);
        mResultHolder.addCallback(this);
        setWillNotDraw(false);
        mInitHandler = new Handler() {
        	@Override 
        	public void handleMessage(Message msg) {
        		initCameraAndStartPreview();