毕加索不能加载图像,某些URL(无特殊字符) [英] Picasso cannot load images for some URL (no special characters)

查看:209
本文介绍了毕加索不能加载图像,某些URL(无特殊字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的毕加索从网上一些图像加载到一个ListView。问题是,当一些图像加载成功,有的只是简单地消失。

I am using Picasso to load some images from online into a listView. The problem is, while some of the images are successfully loaded, some just simply disappear.

成功(成功显示品牌形象):

Successful (The brand image is successfully displayed):

失败(无品牌图像显示,失败):

Fail (no brand image is shown, failed):

当失败的ImageView的消失。这里是我的code:

The ImageView disappears when it fails. Here is my code:

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文件:

Here is my .xml file:

<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>

我已签,这是因为它在毕加索的错误捕获错误失败()方法。

I have checked that it fails because it catches an error in Picasso's error() method.

这里是失败的链接之一。

这里是一个失败的链接。

Here is another failed link.

这里是一个成功的链接。

Here is a successful link.

出现该问题对我好几次。我怀疑问题在于拟合()和centerInside()方法,因为当我删除这两个方法,问题解决了。然而,如果没有这两种方法,我的图片根本就不适合的大小。

The problem occurs to me several times. And I suspect the problem lies with fit() and centerInside() methods, since after I remove those two methods, problem solved. Yet without those two methods, my images simply don't fit the size.

推荐答案

嘿尝试只concatanate您的网址的http://。对于没有HTTP某种原因,Picassa中不会加载图像://。
所以,只是接下来的事情,尝试

Hey try just concatanate your url to "http://". For some reason picassa wont load image without http://. So just try with next thing

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

这篇关于毕加索不能加载图像,某些URL(无特殊字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆