Android: Scale whole image to fit ImageView and keep aspect ratio

It took me a while to figure out, but it's not ScaleType.FIT_XY that does the trick but FIT_CENTER.

FIT_XY will stretch both width and height to fit the ImageView.

Remember to use ImageView.setImageDrawable() or setImageBitmap() rather than setBackgroundDrawable().

Source: Android: Scale a Drawable or background image?

Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog