18

I am using an ImageView in Android where I initially set the layout_height and layout_width to wrap_content as well as set the maxHeight and maxWidth attributes.

This is how it looks like in my layout:

<ImageView
    android:id="@+id/profileImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxWidth="226dp"
    android:maxHeight="174dp"
    android:background="@drawable/photo" />

But when I pick a picture from the gallery then it covers my entire screen, ignoring the maxWidth and maxHeight. How can I resolve this issue ?

PLNech
  • 3,087
  • 1
  • 23
  • 52
N Sharma
  • 33,489
  • 95
  • 256
  • 444
  • You mean you're sending the image to another activity to display on click? – tachyonflux Dec 08 '14 at 19:56
  • 1
    I am picking image from gallery and showing in this `imageview` and when I pick any big size image then it covers almost entire screen. It ignores the maxWidth and maxHeight – N Sharma Dec 08 '14 at 19:56

1 Answers1

81

Add android:adjustViewBounds="true"

tachyonflux
  • 20,103
  • 7
  • 48
  • 67