Camera preview stretches after accepting granular resolution

I have created a camera app that uses both Camera and Camera2 API. The problem occurs when using Camera2 and Granular Permissions.

The app starts up fine and the preview looks great. But only on first launch, when the user accepts the camera and storage permissions, the camera preview you see is stretched.

NOTE. On lower API level devices (API 16 - API 22) that don't use granular permissions, the preview is always correct!

Here are some screenshots to see for yourself:

Stretched preview Stretched

Regular preview Normal

My app is OpenSource and available on GitHub. Here are some of the classes that might be causing the problem:

CameraSourcePreview.java

AutoFitTextureView.java

Camera2Source.java

+3


source to share


1 answer


If you only want to display these images, you can try dependencies such as "Picasso" or "Glide". These two will help you customize the size, scale type, etc. At run time. You can easily tweak both of them and they will not allow these images to stretch.



-2


source







All Articles