title: Android - resize image in gallery based on device resolution
body: <p>I have an Android app that pulls in images from the Web. 
  However when I set:</p>
  
  <pre><code>&lt;supports-screens android:anyDensity="true" /&gt;
  </code></pre>
  
  <p>the gallery appears to be set to the minimum supported resolution.</p>
  
  <p>Here is the gallery layout definition:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;LinearLayout android:id="@+id/GalleryLayout"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:background="#000000"
                &gt;
  
  &lt;Gallery xmlns:android="http://schemas.android.com/apk/res/android"
           android:id="@+id/gallery"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:spacing="1dip"
           android:gravity="center_vertical|center_horizontal|center"
  /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and the getView class:</p>
  
  <pre><code>ImageView i = new ImageView(mContext);
  i.setImageDrawable(drawablesFromUrl[position]);
  i.setLayoutParams(new Gallery.LayoutParams(400, 300));
  i.setScaleType(ImageView.ScaleType.FIT_XY);
  i.setBackgroundResource(mGalleryItemBackground);
  </code></pre>
  
  <p>Is there a way to detect the resolution used and then resize the images in the gallery so they stretch to the width of the screen?</p>