1

I am building a custom camera app. To make it look good, I have to adjust the camera preview dimensions based on the device's supported aspect ratio. I searched on google and stackoverflow but couldn't find the solution I'm looking for. Please help me.

What I've tried :

There is an API method getSupportedPreviewSizes that returns a list of supported camera preview sizes. I tried using the getOptimalPreviewSize method suggested in this post but it's not returning the best preview size (or) aspect ratio.

My device details :

Honor Holy mobile phone with android 4.4.2.
Screen dimensions : 1280 X 720
Correct aspect ratio : 4/3

But here's the twist. If I click a picture from my camera app and open it in the gallery app, the imageview scales automatically to the correct 4/3 aspect ratio. How does the android system detect this aspect ratio for the device? How can I also get it? If I can get the best aspect ratio for the device, I can resize my camera preview to look good.

Community
  • 1
  • 1
Lusid
  • 21
  • 6
  • so what is wrong with `getSupportedPreviewSizes` method? what does it return? – pskink Oct 21 '16 at 08:24
  • getSupportedPreviewSizes() returns 1280 X 720 which also happens to be the device screen size. But if I use full device screen, camera preview is stretched vertically. To maintain the 4/3 aspect ratio, the best preview size should be 960 X 720. – Lusid Oct 21 '16 at 09:59

0 Answers0