android - 使用 Glide 下载位图时会失去透明度
问题描述
我正在尝试使用 Glide 库(版本 4)在 android 应用程序中下载位图图像,但是当我这样做时,图像的透明度会丢失,并被白色背景取代。
我尝试使用以下命令:
Glide.with(this).load(url).into(imageView);
Glide.with(this).asBitmap().load(url).into(imageView);
和
Glide.with(this).load(url).apply( new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888).encodeFormat(Bitmap.CompressFormat.PNG)).into(imageView);
但是似乎没有任何效果。
以下是该应用程序的一些屏幕截图:
这就是它的外观。
(貌似我用png图片的时候,红色背景是ImageView的背景,图片背景是透明的。)
这是位图
的样子(透明背景变成白色。)
非常感谢。
解决方案
据我所知,没有 BMP 格式的 alpha 通道 https://en.wikipedia.org/wiki/BMP_file_format
推荐阅读
- android - 无法在已部署的反应本机应用程序上使用 IP 地址进行本地网络调用
- spring - 在聊天应用程序上建立相同服务的 Pod 间通信
- sharepoint-online - 使用 pnp.js 作为 CDN 在线项目
- excel - 仅复制 WorkSheet VBA 代码而不是数据
- python - str 的 .index 方法如何在 python 中工作?
- sql - 使用 SQL 查询从表中提取数据
- python - *= 数组和整数之间的乘数问题
- c++ - 循环中的向量 (CPP) 打印问题
- spring-boot - 如何修复枚举的休眠“findBy”输入?
- python - 在这个 while 循环条件下发生了什么?