Android picasso image resize

android picasso using resize

Calling the android picasso library and passing image dimensions into the resize method

We return to the origins of this tutorial series and call the android picasso image resize feature. If this is not used picasso will load the full images. Which will have an obvious impact on the scrolling speed of the android recyclerview image gallery.

CODE AVAILABLE ON GITHUB

You can download the code from github at this link picasso code and then you will need to call the Tag “picasso_with_resize” or else you can run this command

git clone --branch picasso_with_resize https://github.com/mobapptuts/recyclerview_image_gallery.git

CODE DETAILS

Add this line to the dependenceies

build.gradle

compile 'com.squareup.picasso:picasso:2.5.2'

Call picasso from the ImageAdapter

ImageAdapter

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    File imageFile = imagesFile.listFiles()[position];
    Picasso.with(holder.getImageView().getContext())
            .load(imageFile)
            .resize(200, 200)
            .into(holder.getImageView());
}

RUN & VIEW THE SCROLLING PERFORMANCE

 

About The Author
-

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>