Scale an image up to fill entire ImageView in Android

后端 未结 4 525
天命终不由人
天命终不由人 2021-01-31 07:16

I\'d like to scale an image up to take up the entire size of an ImageView. This is subtly different than using scaleType=fit_center because fit_center will leave b

4条回答
  •  太阳男子
    2021-01-31 07:51

    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    

    This worked for me to fit the image inside the whole image view, plus it make sense that it says "ScaleType.FIT_XY" to fit the X and Y axis of the imageView.

    From the xml file it would be:

    android:scaleType="fitXY"
    

提交回复
热议问题