0

I have an activity that shows a imageview with a random bitmap from assets folder. I'm loading the image view with this code:

    ImageView imv = new ImageView(ctx);
    imv.setAdjustViewBounds(true);
    imv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imv.setImageBitmap(this.myBitmap);

Also the gravity of the image is set to top of the screen with layout params containing Gravity.TOP

I must use CENTER_CROP because my image sometimes is longer than the height of the screen, and because some other particualirities of my app. I can't use FIT_XY because it deforms my image. I tryed removing center_CROP and did not work, because i want that the image haves the full width of the screen, and without center_crop the image is scaled down.

The problem is that when the bitmap haves more height than the screen height, the image is not starting on the top of the screen, some portion of the upper zone of the image is not being displayed.

How can i avoid that problem?

Thanks

NullPointerException
  • 36,107
  • 79
  • 222
  • 382

0 Answers0