When an ImageView scales its source image to fit inside its bounds, by default it scales by width and keeps aspect ratio. Great, but it doesn’t reduce the height of the ImageView to compensate, so you end up with large blank areas above/below the image to compensate. Two things need to be done to fix this:

  1. add android:anyDensity=”true” to your manifest (you should be pre-scaling these images based on dip anyway)
  2. Log your bitmap.getHeight()/Width() and ImageView.getMeasuredHeight()/Width() and adjust your scaling so that it’s not getting scaled at all – that way, the height shouldn’t push out the imageview.
Advertisements