Hello!.
The previewView on this device (SM-G570M) is
stretched.
I've tried a lot of things, but I can't fix it.
Library Version: (same issue in all versions)
androidx.camera:camera-camera2:1.0.0-beta11
androidx.camera:camera-view:1.0.0-alpha18
Source code
Aspect ratio:
private fun aspectRatio(width: Int, height: Int): Int {
val previewRatio = max(width, height).toDouble() / min(width, height)
if (abs(previewRatio - RATIO_4_3_VALUE) <= abs(previewRatio - RATIO_16_9_VALUE)) {
return AspectRatio.RATIO_4_3
}
return AspectRatio.RATIO_16_9
}
Preview Builder:
val screenAspectRatio = aspectRatio(Utils.getDisplayWidth(applicationContext), Utils.getDisplayHeight(applicationContext))
imagePreview = Preview.Builder().apply {
setTargetAspectRatio(screenAspectRatio)
setTargetRotation(preview_view.display.rotation)
}.build()
preview_view.scaleType = PreviewView.ScaleType.FILL_CENTER
imagePreview.setSurfaceProvider(preview_view.surfaceProvider)
Thanks in advance!