Loss of transparent background when loading an external PNG image

I show the external image in the image view, loading it like this:

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

Then set this bitmap to ImageView as follows:

 imageView.setImageBitmap(bitmap); 

This works well, except that one of the images is PNG, and I lose the transparent background when using BitmapFactory .

Can someone tell me how can I keep a transparent background?

+6
source share
1 answer

not sure if this will help, but try this tip and add options to make sure your image is pulled in like ARGB_8888

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

+2
source

Source: https://habr.com/ru/post/909030/


All Articles