- Common ways to obtain SurfaceView
private void myMethod () {SurfaceView s =
Context context;new SurfaceView(context)
View view;(SurfaceView) view.findViewById(id)
ViewStub viewStub;(SurfaceView) viewStub.inflate()
- Smart code suggestions by Codota
}
@SuppressWarnings("SuspiciousNameCombination") @Override public void onCameraSizeSelected(int width, int height, Frame.ROTATE rotate) { if (rotate == Frame.ROTATE.BY_90_CCW || rotate == Frame.ROTATE.BY_90_CW) { previewWidth = height; previewHeight = width; } else { previewHeight = height; previewWidth = width; } cameraPreview.requestLayout(); } }
/** * Update the camera width and height variables, then request a resize of the SurfaceView. * Notice that CameraHelper notifies us of the physical, pre-rotation width and height of the camera * frames, so we need to account for possible rotation in this method. */ @Override public void onFrameSizeSelected(int width, int height, Frame.ROTATE rotation) { if (rotation == Frame.ROTATE.BY_90_CW || rotation == Frame.ROTATE.BY_90_CCW) { previewHeight = width; previewWidth = height; } else { previewWidth = width; previewHeight = height; } surfaceView.requestLayout(); }