我正在通过首先下载外部图片来在图像视图中显示它:
bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());
然后像这样将位图设置给
ImageView
:imageView.setImageBitmap(bitmap);
这个方法很好用,但是其中一张图片是PNG格式的,使用BitmapFactory
后会失去透明背景。
有没有人可以告诉我如何保留透明背景?
我正在通过首先下载外部图片来在图像视图中显示它:
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)