How to exactly fit camera preview to the screen

361 views Asked by At

I need to have a portrait Activity with and ActionBar and fill the rest of the screen with camera preview. I should not squeeze or strech the image.

On some devices the ratio of the screen does not fit the ratio of avilable camera outputs. The action bar decreases the available height, too.

For example, display size of a Sony Xperia T2 Ultra D5303 is 1208x720. However, the avilable camera sizes given by getSupportedPreviewSizes() are:

1200x1600
720x1280
720x960
480x720
480x640
320x480
288x352
240x320
144x176

The optimal camera output (th one with closest ratio) is 720x1280. Thus, camera preview does not fill the screen, there are black blocks both on left and right.

Is there a way of filling the screen without deteriorating the image? (cropping from top and bottom, perhaps)

0

There are 0 answers