ImageView one dimension to fit free space and second evaluate to keep aspect ration

I found where is problem. Default implementation of ImageView can’t enlarge image. If image is bigger than screen width android:adjustViewBounds=”true” works correctly and adjust height to keep aspect ratio of image. But if image is smaller that screen width it don’t upscale it.

This is cause by this code

if (newHeight <= heightSize) {
    heightSize = newHeight;
} 

in ImageView class (on line 688, API 10)

I made special child of ImageView which allow enlarge image to fit width.

Here is: https://gist.github.com/tprochazka/5486822

Leave a Comment