下载外部PNG图像时丢失透明背景



我在图像视图中显示外部图像,首先下载如下:

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

然后将此位图设置为ImageView,如下所示:

imageView.setImageBitmap(bitmap);

这一切都很好,除了其中一个图像是PNG,并且我在使用BitmapFactory时丢失了透明背景。

有人能告诉我如何保持透明的背景吗?

不确定这是否会有所帮助,但请尝试遵循此建议并添加"选项",以确保您的图像被拉入为ARGB_8888

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

最新更新