I need an ImageView
scale it image until fill the parent horizontally.
If the imageview background is red, and the rest of the content (below the image) is the green I'm looking for the result shown by the Picture 1. That result is obtained automatically if the image width is higher than the screen width.
But if is a small picture like in the picture 2. the best result I can get is the picture 3 (setting the ImageView width and height to fill_parent and the scaleType to FitStart
The picture 4 is obtained setting height= wrap_content, width= fill_parent
, scaleType= CenterCrop
. It should scale vertically to show the entire image, but as the scaleType says it crops it.
Any ideas for getting the picture 1 even if the image is small?
Will grant a bounty of 50 to a working answer
I found an easy solution that works really good for me. Set width and height as you wish, e.g.:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Then you also set this setting:
android:adjustViewBounds="true"
"adjustViewBounds" defaults to false (which I find odd) but setting it makes it easy to fill the image in the imageview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With