title: Maximum width and height for ImageView in Android
body: <p>So I have an ImageView set with </p>
  
  <pre><code>android:maxHeight="100px"
  android:maxWidth="250px"
  android:minHeight="100px"
  android:minWidth="250px"
  android:scaleType="centerInside"
  </code></pre>
  
  <p>This image view is used to show a picture that is obtained from the gallery or camera. In both cases, the image is not resized to fit inside the imageview, it just stretches its space as much as it needs.</p>
  
  <p>Any idea how to make it stay inside those bounds?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>&lt;EditText
      android:layout_height="wrap_content"
      android:layout_width="fill_parent"
      android:id="@+id/txtDescription"
      android:layout_below="@+id/txtSubject"
      android:inputType="textMultiLine"
      android:height="80px"
      android:hint="@string/description"&gt;&lt;/EditText&gt;
  
  &lt;EditText
      android:layout_height="wrap_content"
      android:layout_below="@+id/txtDescription"
      android:layout_width="fill_parent"
      android:id="@+id/txtMorada"
      android:hint="@string/address" /&gt;
  
  &lt;ImageButton
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_below="@+id/txtMorada"
      android:id="@+id/btGPS"
      android:layout_alignParentLeft="true"
      android:src="@drawable/ic_menu_compass"&gt;&lt;/ImageButton&gt;
  
  &lt;ImageView
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_below="@+id/btGPS"
      android:layout_marginTop="25px"
      android:id="@+id/imgPoint"
      android:src="@drawable/google_logo_small"
      android:maxHeight="100px"
      android:maxWidth="250px"
      android:minHeight="100px"
      android:minWidth="250px"
      android:scaleType="centerInside"&gt;&lt;/ImageView&gt;
  
  &lt;ImageButton
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_toRightOf="@+id/imgPoint"
      android:id="@+id/btGallery"
      android:layout_below="@+id/btCamera"
      android:src="@drawable/ic_menu_gallery"
      android:layout_alignParentRight="true"&gt;&lt;/ImageButton&gt;
  
  &lt;Button
      android:layout_height="wrap_content"
      android:layout_width="fill_parent"
      android:layout_marginTop="10px"
      android:id="@+id/btSubmit"
      android:layout_below="@+id/btGallery"
      android:text="@string/submit"&gt;&lt;/Button&gt;
  
  &lt;ImageButton
      android:layout_height="wrap_content"
      android:id="@+id/btMap"
      android:layout_below="@+id/txtMorada"
      android:layout_width="wrap_content"
      android:layout_alignParentRight="true"
      android:src="@drawable/ic_menu_mapmode"&gt;&lt;/ImageButton&gt;
  
  &lt;TextView
      android:layout_below="@+id/txtMorada"
      android:layout_width="wrap_content"
      android:layout_toLeftOf="@+id/btMap"
      android:layout_height="wrap_content"
      android:id="@+id/lblNewPointLatitude"
      android:text="Latitude"&gt;&lt;/TextView&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_toLeftOf="@+id/btMap"
      android:layout_height="wrap_content"
      android:id="@+id/lblNewPointLongitude"
      android:layout_below="@+id/lblNewPointLatitude"
      android:text="Longitude"&gt;&lt;/TextView&gt;
  
  &lt;ImageButton
      android:layout_below="@+id/btMap"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_toRightOf="@+is/imgPoint"
      android:id="@+id/btCamera"
      android:layout_marginTop="25px"
      android:src="@drawable/ic_menu_camera"
      android:layout_alignParentRight="true"&gt;&lt;/ImageButton&gt;
  
  &lt;Spinner
      android:layout_height="wrap_content"
      android:id="@+id/spCategoria"
      android:layout_width="fill_parent"
      android:prompt="@string/spCategoriaPrompt"&gt;&lt;/Spinner&gt;
  
  &lt;Spinner
      android:layout_height="wrap_content"
      android:id="@+id/spSubcategoria"
      android:layout_below="@+id/spCategoria"
      android:layout_width="fill_parent"
      android:prompt="@string/spSubcategoriaPrompt"&gt;&lt;/Spinner&gt;
  
  &lt;EditText
      android:layout_height="wrap_content"
      android:layout_below="@+id/spSubcategoria"
      android:layout_width="fill_parent"
      android:id="@+id/txtSubject"
      android:hint="@string/subject"&gt;&lt;/EditText&gt;
  
    &lt;/RelativeLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>