kmb64
kmb64

Reputation: 1513

Losing transparent background when downloading an external PNG image

I'm displaying an external image in an image view by fist downloading it like this:

bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());

Then setting this bitmap to the ImageView like this:

imageView.setImageBitmap(bitmap);

This works all good except that one of the images is a PNG and I lose the transparent background when using the BitmapFactory.

Can anyone tell me how I can keep the transparent background?

Upvotes: 6

Views: 3123

Answers (1)

Yevgeny Simkin
Yevgeny Simkin

Reputation: 28349

not sure if this will help, but try following this advice and adding Options to make sure that your image is pulled in as ARGB_8888

http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeFile(java.lang.String, android.graphics.BitmapFactory.Options)

Upvotes: 2

Related Questions