title: Android: Having problems with stretching/scaling on an image button
body: <p>I have been struggling with what I think is something simple.  I am setting an image on an image button using a class.  I want the image to fit the constraints of the screen, but <strong>without</strong> stretching.  That is, if it's too wide to fit the screen, I want the height to be scaled to accommodate so that it doesn't get <em>stretched</em>.  And if the height is too tall, I want the image height to be reduced, thereby shrinking the width too.</p>
  
  <p>I have seen this question asked a couple times and I have tried every bit of the advice, but it makes absolutely no difference for me.  I think this may have something to do with usnig an ImageButton instead of an ImageView?</p>
  
  <p>Here are some relevant chunks of code (badly broken) ...</p>
  
  <p>In my class:</p>
  
  <pre><code>          ImageView img = (ImageButton) dialog.findViewById(R.id.fullsizeimage);
            img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);  //Changing ScaleType here has no effect
            img.setImageBitmap(useThisBitmap);
  </code></pre>
  
  <p>And here is the xml layout contents ...</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  
  &lt;ImageButton
      android:id="@+id/fullsizeimage"
      android:background="@null"
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent"
      android:adjustViewBounds="true"
      /&gt;
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Some of that junk in the XML file is probably wrong.  But I have changed it so many times, and it has ZERO effect.</p>
  
  <p>Any and all advise is <em>greatly</em> appreciated.</p>