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
  • 4,001
  • 1
  • 22
  • 49
N Sharma
  • 31,202
  • 88
  • 240
  • 427
  • 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

79

Add android:adjustViewBounds="true"

tachyonflux
  • 19,843
  • 7
  • 46
  • 66