Scaling a SurfaceView will not render the artifact

Public methods explain
void draw(Canvas canvas) Manually render various views onto a given canvas
boolean gatherTransparentRegion(Region region) RootView uses it to perform optimizations when the view hierarchy contains one or more SurfaceViews.
SurfaceHolder getHolder() Returns the SurfaceHolder, used to access and control the SurfaceView
void setSecure(boolean isSecure) Controls whether the content of the surface view should be considered secure, preventing it from appearing in screenshots or being viewed in an insecure display. Note that this setting must be set before the window is included in the window view of the window manager.
void setVisibility(int visibility) SurfaceView visible Settings
void setZOrderMediaOverlay(boolean isMediaOverlay) Whether surfaceView1 is placed on another surfaceView2 view
setZOrderOnTop(boolean onTop) In your own window, set the top-level display

The method of protected

Protected methods explain
void dispatchDraw(Canvas canvas) Draw the subview with draw
void onAttachedToWindow() The view is triggered when it attaches to the window
void onDetachedFromWindow() The view is triggered to detach from the window
onMeasure(int widthMeasureSpec, int heightMeasureSpec) Draws the width and height of the view
onWindowVisibilityChanged(int visibility) Fired when the view is continuously visible and invisible

<2> SurfaceHolder API

Return value (abstract) methods explain
void addCallback(SurfaceHolder.Callback callback) Add a callback interface for the entire holder
Surface getSurface() Access the Surface object directly
Rect getSurfaceFrame() Gets the size of the surface
boolean isCreating() Use this method to find out if you are in the process of creating from a callback method.
Canvas lockCanvas() Start editing the surface pixels
void unlockCanvasAndPost(Canvas canvas) End Editing surface pixels
Canvas lockCanvas(Rect dirty) Start editing surface pixels, but allow special rectangles
default Canvas lockHardwareCanvas() Start editing surface pixels, but return a hardware-accelerated canvas
void removeCallback(SurfaceHolder.Callback callback) Remove the callback interface from holder
void setFixedSize(int width, int height) Modify surface dimensions
void setFormat(int format) Set the pixel format of surface:PixelFormat
abstract void setKeepScreenOn(boolean screenOn) Enable or disable options to open the screen when the interface is displayed.
void setSizeFromLayout() Allows the Surface to be resized according to the layout of its container

< 3 > SurfaceHolder. Callback interface

Overriding methods explain
surfaceChanged(SurfaceHolder holder, int format, int width, int height) Surface changes the callback
surfaceCreated(SurfaceHolder holder) The surface is called back the first time it is created
surfaceDestroyed(SurfaceHolder holder) Surface destruction callback

< two >Camera2 related classes

Android 5.0 API support, the main functions are in Android.hardware. Camera2. The related classes are: 1: CameraManager(and the two callbacks AvailabilityCallback and TorchCallback) 2: CameraDevice(and the callback StateCallback) 3: CameraDevice(and the callback StateCallback) CameraCaptureSession(and two callbacks: CaptureCallback and StateCallback) 4: CaptureRequest(and CaptureRequest.Builder class)+CaptureResult+TotalCaptureResult+CameraCharacteristics, The four classes are inherited base class CameraMetadata 5: receiving data class android. Media. The ImageReader 6: XML layout classes: TextureView (Google demo recommended) or SurfaceView

<1>CameraManager

A system service manager for detecting, describing, and connecting to camera equipment. CameraManager Manager = (CameraManager) Context.getSystemService(context.camera_service); CameraManager Manager = (CameraManager) context.getSystemService (context.camera_service); CameraManager Manager = (CameraManager) Context.getSystemService (Cameramanager.class);

The return value The method name explain
CameraCharacteristics getCameraCharacteristics(String cameraId) Example Query the camera function.
String[] getCameraIdList() Returns a list of currently connected camera devices by identifier, including cameras that may be used by other camera API clients.

openCamera(String cameraId, CameraDevice.StateCallback callback, Handler handler) Opens a connection for the camera with the given ID.

registerAvailabilityCallback(CameraManager.AvailabilityCallback callback, Handler handler) Register a callback to be notified about the availability of the camera equipment.

registerTorchCallback(CameraManager.TorchCallback callback, Handler handler) Register a callback to be notified of the torch Mode status.

setTorchMode(String cameraId, boolean enabled) Sets the flash mode for the flash without turning on the camera device.

unregisterAvailabilityCallback(CameraManager.AvailabilityCallback callback) Delete the previously added callbacks and the callbacks will no longer receive connection and disconnect callbacks.

unregisterTorchCallback(CameraManager.TorchCallback callback) Delete the previously added callback and the callback will no longer receive torch Mode state callbacks.

<1-1>CameraManager.AvailabilityCallback

CameraManager internal class AvailabilityCallback callback

A callback for the camera device or one that cannot be opened.