Android: Picasso enlarging Image on Click?

1.8k Views Asked by At

I was using Picasso for a while now and I'm very satisfied with it. However I'm in need of enlarging an imageview's image which was loaded by Picasso. As in, I simply want to create a zoomImageFromThumb of the image. However the traditional zoomImageFromThumb requires a resource to be present in the project. In my case, Picasso loads it up.. so how do I enlarge an image laoded by Picasso on click of the image view?

My code so far:

ImageBanner= (ImageView) findViewById(R.id.lb_single_image);
Picasso.with(ctx)
        .load("www.flickr.com/randomimage.jpg")
        .placeholder(R.drawable.loading_placeholder)
        .error(R.drawable.error_placeholder)
        .into(ImageBanner);
ImageBanner.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //how do I enlarge the picasso image?
            }
        });
1

There are 1 best solutions below

0
On

Instead of setOnClickListener() you can use PhotoViewAttacher:

    ImageBanner= (ImageView) findViewById(R.id.lb_single_image);
Picasso.with(ctx)
        .load("www.flickr.com/randomimage.jpg")
        .placeholder(R.drawable.loading_placeholder)
        .error(R.drawable.error_placeholder)
        .into(ImageBanner);

PhotoViewAttacher mAttacher = new PhotoViewAttacher(ImageBanner);

Only one line, and it will works.