Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ImageView ScaleType and item height

Tags:

Things looked quite simple first but in the end the result is not good. I have an image which has a width larger than screen's width. So I need to scale it down in my imageview. I looked over the ScaleType options and tried them all but none is ok. First "center" only displays the image centered on the layout, no scaling done. "fitCenter" scales the image to fit in my layout but has a major drawback: the height of the item remains as it would have the large image in it. Take a look at the second screen in the attached image. How can I force the list item, to reduce its height to wrap both the text and the image ?

enter image description here

like image 954
Alin Avatar asked Apr 12 '12 12:04

Alin


Video Answer


2 Answers

Use the scaletype which seems best to you ( I guess you like what you see with fitCenter). The additional thing that you must do is

android:adjustViewBounds="true"

in your ImageView.

or you could go with FitXY but sometimes the result is not exactly what you want.

like image 59
Shubhayu Avatar answered Sep 21 '22 18:09

Shubhayu


use android:scaleType="fitXY"

like image 40
N.Droid Avatar answered Sep 21 '22 18:09

N.Droid