Android-universal-image-loader,android-volley and Picasso three big Android open source components load network picture advantages and disadvantages comparison

Source: Internet
Author: User

Loading the network picture in Android is a very annoying thing, there are many open-source libraries on the Internet to load the network pictures, it is very convenient for us to load the network pictures. Here I mainly introduce myself in the use of volley, Picasso, universal-imageloader Some of the use of sentiment. And the most basic usage introduction.
1.android-volley

    • Set up a picture source for ImageView

    1. ImageView is a ImageView instance
    2. The second parameter of Imageloader.getimagelistener is the default picture resource ID
    3. The third parameter is the resource ID at the time of the request failure and can be specified as 0
    4. Imagelistener listener = Imageloader.getimagelistener (ImageView, Android. R.drawable.ic_menu_rotate, Android. R.drawable.ic_delete);
    5. Mimageloader.get (URL, listener);
Copy Code

    • Using Networkimageview
Volley provides a new control Networkimageview to replace the traditional ImageView, the Picture property of this control can be
    1. Mimageview.setimageurl (URL, imageloader)
Copy the code to set it. Furthermore, this control automatically cancels the network request when it is detach from the parent control, that is, without worrying about the lifecycle of the associated network request.
    1. Mimageloader = new Imageloader (Mrequestqueue, New Bitmaplrucache ());
    2. .... ...
    3. if (holder.imagerequest! = null) {
    4. Holder.imageRequest.cancel ();
    5. }
    6. Holder.imagerequest = Mimageloader.get (Base_ur + Item.image_url, Holder.imageview, r.drawable.loading, R.DRAWABLE.ERROR);
Copy Code
Summary: If your project is a relatively small project, or not very high project, processing relatively simple can use the library, this library is a Google I/O release of an open source library. The use of this library in the image processing, not provide any image processing operations, personal feeling this library is mainly in the network data connection is better, in the picture processing is not perfect, strong.


2.Picasso
The use of Picasso loading network images is simple and requires a single line of code to be done.
    1. Picasso.with (context). Load (URL). Resize (). Centercrop (). into (ImageView)
Copy Code

Picasso has the following characteristics:
    • Handles ImageView recycling in adapter and cancels the download process that has reclaimed ImageView
    • Complete complex image transformations with minimal memory, such as converting downloaded images to rounded corners
    • Automatically add disk and memory caches

Summary: If you have a project inside, there are some specific requirements for the picture, it is recommended to use this library, but this library when you need to do something specific to the picture, such as loading rounded rectangle picture, cropping the picture as a circle, you need to write some of the operation, if the foundation is not good enough to feel very difficult. There is this library we can only see the results, unable to care about the download process of the picture.

3.universal-imageloader

  • First, configure the Imageloaderconfiguration class to implement the global Imageloader implementation. You can choose to initialize the class in application.
  • When using Imageloader for picture loading, first instantiate the Imageloader


Summary: This library has a detailed configuration to load the network pictures. Can be based on personal preference, some configuration and so on. And can realize the picture downloading process monitoring. and can support the picture after the download is complete, display a circle or rounded rectangle picture.

Android-universal-image-loader,android-volley and Picasso three big Android open source components load network picture advantages and disadvantages comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.