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

前端 未结 1 1244
忘了有多久
忘了有多久 2020-12-03 11:00

I need something like for Android . I mean resize width to all available space (shrink or enlarge widt

相关标签:
1条回答
  • 2020-12-03 11:39

    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

    0 讨论(0)
提交回复
热议问题