scaled image not visible in android
<p>I have to make an application in which i am downloading an image from a URL and i have to show the image to after scaling.</p>

<p>The default size of the image is 220x200</p>

<p>Scaled size of image is 55x50</p>

<p>Here is my code for doing the above:</p>

<p>XML file layout:</p>

<pre><code>        &lt;ImageView android:id="@+id/productimage"
        android:layout_gravity="center_vertical|left" android:layout_width="55dip"
        android:layout_height="50dip" android:adjustViewBounds="true" /&gt;
</code></pre>

<p>Here is the code for downloading the image and resizing it:</p>

<pre><code> ImageView productImage = (ImageView) arg1
                        .findViewById(R.id.productimage);
                if (!headerDetails[1].equals("null")) {
                    Bitmap image = getImage(headerDetails[1]);
                    if (image != null) {
                        try {
                            productImage
                                    .setImageBitmap(Bitmap
                                            .createScaledBitmap(
                                                    image,
                                                    productImage
                                                            .getMeasuredWidth(),
                                                    productImage
                                                            .getMeasuredHeight(),
                                                    false));
                        } catch (Exception e) {

                            e.printStackTrace();
                        }
                    }
                }
</code></pre>

<p>Here is the class for downloading the image:</p>

<pre><code>    private Bitmap getImage(String address) {
    try {
        Log.i("getimage", address);
        URL url = new URL(address);

        URLConnection conn = url.openConnection();
        conn.connect();
        InputStream is = conn.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        Bitmap bm = BitmapFactory.decodeStream(bis);
        // bis.close();
        // is.close();
        return bm;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
</code></pre>

<p>No exception is being thrown here, hence the image is being downloaded correctly.</p>

<p>OUTPUT: No image is displayed in the imageview.</p>

<p>what am i doing wrong. The size of the image that i want is 55x50 but the size of the image on the net may vary.</p>

<p>thank you in advance.</p>

<p>EDIT:</p>

<p>the bitmap formed after the following code:</p>

<pre><code>Bitmap bm = BitmapFactory.decodeStream(bis);
</code></pre>

<p>does not have a height and a width and it's height and width is set  to -1. What could be going wrong here?</p>

<p>The following exception is also being thrown:</p>

<pre><code>06-23 14:24:41.635: WARN/System.err(16618): java.lang.IllegalArgumentException: width and height  must be &gt; 0
</code></pre>
