In addition to what Lena Bru says about finding a good preview size if there is no exact ratio of the proportions between your CamLayer sizes and the camera preview size, the only option to avoid distortion is to customize the layout of your CamLayer.
The camera’s preview is simply stretched to cover the whole view, regardless of aspect ratio, so for an undistorted view, you need to customize the layout of the view in accordance with the selected preview format. See the Android Developer site for user component documentation ; especially the part about onMeasure.
You want to tell the width and height based on the proportion of the preview, and you may need to trigger a relay of your user interface when setting the size of the camera’s preview to update the view size.
source share