title: Downloaded image gets resized
body: <p>I am downloading an image from the internet which has the following dimensions: 128px x 128px
  After the download the image is used as the background of an <code>ImageButton</code> but when the button is displayed, the image is smaller than it was before it was downloaded. For the download i use an <code>AsyncTask</code> ... here is my code:</p>
  
  <pre><code>public class ImageDownloaderButton extends AsyncTask&lt;String, Void, Bitmap&gt; {
  
      private String url;
      private final WeakReference&lt;ImageButton&gt; imageButtonReference;
  
      public ImageDownloaderButton(ImageButton imageButton) {
          imageButtonReference = new WeakReference&lt;ImageButton&gt;(imageButton);
      }
  
      @Override
      protected Bitmap doInBackground(String... params) {
          url = params[0];
          try {
              if (url.equals("")) {
                  return null;
              }
              return BitmapFactory.decodeStream(new URL(url).openStream());
          } catch (MalformedURLException e) {
              e.printStackTrace();
              return null;
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          }
      }
  
      @Override
      protected void onPostExecute(Bitmap result) {
          if (isCancelled()) {
              result = null;
          }
          if (imageButtonReference != null) {
              ImageButton imageButton = imageButtonReference.get();
              if (imageButton != null) {
                  if (result != null) {
                      imageButton.setImageBitmap(result);
                  } else {
                      imageButton.setImageResource(R.drawable.noimageavailable);
                  }
              }
          }
      }
  
      @Override
      protected void onPreExecute() {
          if (imageButtonReference != null) {
              ImageButton imageButton = imageButtonReference.get();
              if (imageButton != null) {
                  imageButton.setImageResource(R.drawable.noimageavailable);
              }
          }
      }
  }
  </code></pre>
  
  <p>The codesnippet where the download is startet:</p>
  
  <pre><code>ImageButton imageButton = (ImageButton) view.findViewById(R.id.icon_image);
  ImageDownloaderButton downloader = new ImageDownloaderButton(imageButton);
  downloader.execute(supp.getPicture()); //the picture is the url
  imageButton.setOnClickListener(createOnClickListener(supp.getId()));
  </code></pre>
  
  <p>and finally here is the xml file which contains the <code>ImageButton</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/icon_with_text"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:gravity="center_horizontal"&gt;
  &lt;ImageButton
      android:id="@+id/icon_image"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@android:color/transparent"
      android:layout_gravity="center"
      android:onClick="myClickHandler"/&gt;
  &lt;TextView
      android:id="@+id/icon_text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:textColorHighlight="#656565"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Can anyone explain to me why the image is resized?</strong> The image (noavailableimage) that is shown while the AsyncTask is downloading is 128x128px and this one is shown in the correct size.</p>
  
  <p>Screenshots:</p>
  
  <p>
  <img src="https://i.imgur.com/mngHD.png" alt="aphotheke">
  <img src="https://i.imgur.com/E5IKh.png" alt="baecker"></p>
  
  <p>Emulator:</p>
  
  <p><img src="https://i.imgur.com/9C5eW.png" alt="mainmenu">
  <img src="https://i.imgur.com/lsNsl.png" alt="supplier"></p>