How to set both min and max size for an ImageView in Android

前端 未结 3 1827
無奈伤痛
無奈伤痛 2021-01-02 02:40

I would like so specify both min. width/height and max. width/height for an ImageView. The image should be scaled to fit.

Doing this:



        
3条回答
  •  旧巷少年郎
    2021-01-02 02:47

    This used to be pretty much impossible with just XML, but now with ConstraintLayout, it's quite simple.

    
    
        
    
    

    You can use a scaleType of fitXY or centerCrop; others will not force the image to fit the ImageView.

提交回复
热议问题