I'm using Camera2 but the preview is stretching. Please help me.I have uploaded images please check. I'm new to android.
Asked
Active
Viewed 3,927 times
1
-
Thank you for your quick reply. I'm using this code https://android.googlesource.com/platform/frameworks/base/+/ee699a6/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java – user1624508 May 27 '17 at 05:22
-
what is `Size optimalSize`? – pskink May 27 '17 at 05:25
-
Hi, I don't know, I'm bit new to this API. I think that's the PreviewSize as per the Device – user1624508 May 27 '17 at 05:28
-
so check your sources what it is used for – pskink May 27 '17 at 05:29
-
Well I'm trying the source sir. – user1624508 May 27 '17 at 05:31
-
please take a look at this https://stackoverflow.com/a/43516672/7334112 this would be helpful. Thank you – Ronak Patel Sep 16 '22 at 09:28
1 Answers
1
Please take a look at the official sample apps from Google, such as Camera2Basic, or the new CameraView library. They handle aspect ratio issues such as what you're seeing.

Eddy Talvala
- 17,243
- 2
- 42
- 47
-
Yes, CameraView is working well. I have been testing CameraView on Android 4.4, Android 5.1 and Android 7.0. – Alexander Lubyagin Nov 16 '17 at 18:33
-
Actually, the aspect ratio [bug](https://github.com/googlesamples/android-Camera2Basic/issues/69) in Camera2Basic [was fixed](https://github.com/googlesamples/android-Camera2Basic/pull/83) after this answer was posted. – Alex Cohn Dec 06 '17 at 15:23