开发者

How do you scale a square image without losing the aspect ratio (even if the layout is not square)

开发者 https://www.devze.com 2023-03-18 06:14 出处:网络
I\'d like to create a square layout so I could scale up/and down a square image I have - using \'android:scaleType=\"fitXY\"\'.

I'd like to create a square layout so I could scale up/and down a square image I have - using 'android:scaleType="fitXY"'. Other scale types don't work because they don't scale up the image.

The problem is that I can't create an exact square layout. In order for the scaling up to work, I need to give a very big width/height (like 150dp * 150dp).

Sometimes, the image is found within another layout, which it's size I don't know. If the width/height of the layout is smaller than 150dp, the whole layout is filled and the image loses it's aspe开发者_高级运维ct ratio.

How do you scale up and down a square image without losing the aspect ratio?

Thanks.


ImageView.ScaleType

ImageView.ScaleType CENTER_CROP 
0

精彩评论

暂无评论...
验证码 换一张
取 消