Picasso Library Use for Image Loading in Android

Save

What is Picasso Library?

A powerful image downloading and caching Library for Android. By its use Developer, to load an image in “android application” with one line of code, without worry about caching, transformation and threading an image to load.

 

Syntax:

 

where “this” is  Activity object, “url” is image address URL (source) and “imageview” is ImageView (destination).

Picasso methods –

  1. resize(width, height), use for resizing an image.
  2. onlyScaleDown(), use with resize() method when small image not to resize.
  3. centerInside(), use for, when an image not  fills the bounds of ImageView.
  4. fit(), when ImageView is well defined in size then  it resizes the image to ImageView width and height.
  5. centerInCrop(), use for, when an image fills the bounds of ImageView.

memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) ,

NO_CACHE- Skips memory cache lookup when processing a request.

NO_STORE- Skips storing the final result into the memory cache. Useful for one-off requests to avoid evicting other bitmaps from the cache (it is needed, when loads an image only once).

 

Out of memory Exception :     It happened when loading large size images . So, it solved by resizing the images. if we use resize(width, height) then the image is not resized as the aspect ratio. So we use a custom transform class using transform() method.

Example.

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.

Josh Arnold

Josh Arnold

Owner, Shop ATV Escape

Talk to Sales

Global

Live Chat
Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home