android - 如果图像是 HTTP 格式,Imageview 将不会显示带有 piccsso 的图像
问题描述
我正在使用毕加索将图像从 URL 膨胀到 Imageview:
@Override
public void onBindViewHolder(@NonNull HeroesViewHolder holder, int position) {
Hero currentHero = heroList.get(position);
String str = String.join(",", currentHero.abilities);
holder.heroTitle.setText(currentHero.title);
holder.heroAbilities.setText(str);
Picasso.get().load(currentHero.image).resize(500, 500).into(holder.heroesImage);
}
问题是 HTTP 协议的所有内容都不会显示在模拟器和物理设备上,只会显示 HTTPS 协议。它没有显示它,而是留下了一个黑色空间。
HTTP 协议的图像也是 .png 扩展名,如果这与此有关。
我该如何解决这个问题?
解决方案
请尝试以下代码:
Picasso.with(this) // Activity context
.load(currentHero.image) // Set URL
.resize(100,100) // Resize the image
.placeholder(getResources().getDrawable(R.drawable.ic_defuser)) // Default Image
.error(getResources().getDrawable(R.drawable.ic_defuser))
.into(holder.heroesImage); // Imageview
推荐阅读
- laravel - 尝试发送包含 Laravel + Vue 集合的对象时出错
- c# - 消息=无法将“System.Windows.Forms.PlaceholderTextBox”类型的对象转换为“Bunifu.UI.WinForms.BunifuTextBox”类型
- coq - 为什么“仅打印”符号会修改解析器
- python - 训练测试拆分后将数据附加到训练数据集
- oracle - 如何在 Oracle SQL live 中导入 excel 文件
- python - 如何按 Pandas DataFrame 中的给定列表对列进行排序?
- javascript - “setColumnDefs”不适用于版本 26.1.0 (Angular)
- android - 如何强制媒体流转为语音流?
- python - ParserError:小时必须在 0..23:09/05/2019 24:00
- mysql - mysql查询。需要用名字和姓氏搜索全名,反之亦然