title: Stretch ImageView so that it fills the whole screen in a Dialog
body: <p>I have an app with a lot of small images in it. To provide an "enlarge" function I'd like to open a Dialog (realized as an <code>Activity</code> with dialog theme) containing only an ImageView with the selected picture.</p>
  
  <p>The image/dialog should be displayed as large as possible (i.e. scaled proportionally to the screen size) but also only as large as needed. That means that for a landscape picture the dialog should also be in a landscape format instead of filling the whole screen (with black bars at the top/bottom).
  Basically I want the dialog to be as large as the ImageView and the ImageView as large as possible (while regarding the aspect ratio of the containing image).</p>
  
  <p>Is there a way to achieve that?</p>
  
  <p>Please note that the displayed image might be a lot smaller than the available screen space but it should be scaled up in this case. I can't provide images for different resolutions/screen sizes as it's user-generated content.</p>
  
  <p>My current layout file for the dialog (which works fine for pictures larger than the device display but won't scale up images that are smaller):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:background="@color/image_overlay" &lt;!-- semi transparent background --&gt;
               android:gravity="center"
               android:foregroundGravity="center"&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:scaleType="centerInside"
          android:layout_margin="8dp"/&gt;
  &lt;/FrameLayout&gt;
  </code></pre>