How to scale an Image in ImageView to keep the aspect ratio

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2010-03-26T08:41:15Z Indexed on 2010/03/26 8:43 UTC
Read the original article Hit count: 303

Filed under:

Hi,

In android, I defined an ImageView's layoutWidth to be 'fill_parent' (which takes up the full width of the phone). My question is if the Image i put to ImageView is bigger than the layoutWidth, android will scale it, right?

But what about the height? when android scale it, will it keeps the aspect ratio?

What I find out is, there is some 'white space' at the top/bottom of the ImageView when android scales an image which is bigger than the ImageView. Is that true? If yes, how can I eliminate that white spaces?

Thank you.

© Stack Overflow or respective owner

Related posts about android