Custom View that displays the camera feed for CameraX's
Preview use case.
This class manages the preview
Surface's lifecycle. It internally uses either a
SurfaceView to display the camera feed, and applies required
transformations on them to correctly display the preview, this involves correcting their
aspect ratio, scale and rotation.
PreviewView uses a
SurfaceView to display the preview
stream, be careful when overlapping a
View that's initially not visible (either
View.GONE) on top of it. When the
attached to the display window, it calls
ViewParent.requestTransparentRegion(View) which requests a computation of
the transparent regions on the display. At this point, the
View isn't visible, causing
the overlapped region between the
SurfaceView and the
View to be
considered transparent. Later if the
View becomes visible, it
will not be displayed on top of
SurfaceView. A way around this is to call
ViewParent.requestTransparentRegion(View) right after making the
View visible, or initially hiding the
View by setting its
opacity to 0, then setting it to 1.0F to show it.
The implementation mode of a
Options for scaling the preview vis-à-vis its container
Definitions for the preview stream state.