Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?

前端 未结 17 1037
无人共我
无人共我 2020-11-22 17:07

How to fit an image of random size to an ImageView?
When:

  • Initially ImageView dimensions are 250dp * 250dp
  • The image\'
17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 17:48

    May not be answer for this specific question, but if someone is, like me, searching for answer how to fit image in ImageView with bounded size (for example, maxWidth) while preserving Aspect Ratio and then get rid of excessive space occupied by ImageView, then the simplest solution is to use the following properties in XML:

        android:scaleType="centerInside"
        android:adjustViewBounds="true"
    

提交回复
热议问题