How to make Picasso load images faster?

2020-08-02 02:12发布

问题:

I use Picasso (image downloading library for Android). Picasso website

I charge my image like this:

Picasso.get().load("http://i.imgur.com/myImage.png").into(imageView);

But, if myImage.png is too big, the download become slow. (With bad internet connection of course)

How to make Picasso load images faster?

Can I just make the quality lower by Picasso? Or can I charge them "early" a few seconds before using them?

Note that I cannot touch the file myImage.png

---------------------

EDIT

Any idea how to charge an image "early"? Should I use invisible view and load image into it, then use the same image in my View? How to add an image to cash (By Picasso always)?

回答1:

Picasso has no control over the server fulfilling the network request or the internet connection itself. Using a service like Thumbor might help: https://github.com/thumbor/thumbor



回答2:

No, Picasso loads a smaller version of that image into the view to use less memory, However it has to download the full source image before hand.

Consider uploading smaller images to have shorter download time, You may use multiple versions of your image:

image_thumbnail.png
image_small.png
image_medium.png
image_orginal.png

Download the thumbnail first and then download the small image, Use the bigger images for bigger views.

Yes it is possible to download them "early" but it's not recommend to waste the precious battery and bandwidth on mobile phones.



回答3:

You could try to add this to your android manifest

<application android:hardwareAccelerated="true" ...>

i use this to load videos faster, and it works for me ;) Maybe it'll also work for you



回答4:

Picasso optimize the image automatically loading a smaller version of the image into the ImageView, but if the source image is "big", the load will become slow so i recommend to you optimize the source images.

Check this articles:

Image Optimization

Automating Image Optimization