gpt4 book ai didi

android - Picasso 无法加载某些 URL 的图像(无特殊字符)

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:30 25 4
gpt4 key购买 nike

我正在使用 Picasso 将一些在线图像加载到 listView 中。问题是,虽然有些图像已成功加载,但有些只是简单地消失了。

Successful(成功展示品牌形象):

enter image description here

失败(未显示品牌形象,失败):

enter image description here

ImageView 在失败时消失。这是我的代码:

Picasso.with(mContext)
.load(UrlEncoder.encode(interiorDesign.getBrand_image_url()))
.config(Bitmap.Config.RGB_565)
.error(R.drawable.blank)
.fit()
.centerInside()
.into(holder.brand);

这是我的 .xml 文件:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:orientation="horizontal">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingRight="10dp">
...
</RelativeLayout>

<ImageView
android:layout_width="200dp"
android:layout_height="90dp"
android:paddingBottom="10dp"
android:id="@+id/partial_interior_design_brand" />
</LinearLayout>

我检查过它失败了,因为它在 Picasso 的 error() 方法中捕获了一个错误。

Here是失败链接。

Here是另一个失败的链接。

Here是一个成功的链接。

我多次遇到这个问题。我怀疑问题出在 fit() 和 centerInside() 方法上,因为在我删除这两种方法后,问题就解决了。然而,如果没有这两种方法,我的图像根本不适合尺寸。

最佳答案

嘿,尝试将您的网址连接到“http://”。出于某种原因,picassa 不会在没有 http://的情况下加载图像。因此,只需尝试下一件事

Picasso.with(mContext)
.load("http://".concatenate(url))
.config(Bitmap.Config.RGB_565)
.error(R.drawable.blank)
.fit()
.centerInside()
.into(holder.brand);

关于android - Picasso 无法加载某些 URL 的图像(无特殊字符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com