Search code examples
androidlistviewpicasso

display only centre part of image and on click show full image


how can i display only center portion of image and on click want to display full image in new activity. I'm using listview with image and text portion. I'm displaying image using Picasso library.

Here i'm adding code for click event of imageview

I'm generating imageview as per data size because i had create slider type so.

Picasso.with(Global.mcontext).load(Utils.URL + data.get(position).Image.get(i).Image).fit().error(R.drawable.ic_profile).into(holder.img_playlist[i]);

holder.img_playlist = new ImageView[data.size()];

    holder.layout_playlist_main.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (data.get(position).Image != null && data.get(position).Image.size() > 0) {
                        Intent intent = new Intent(context, ShowImageSecondary.class);
                        Global.Data = data.get(position);
                        context.startActivity(intent);
                    }
                }
            });

can anyone help me


Solution

  • While creating your ImageView in your ListView item,Use this code:

    ImageView image = new ImageView(this);
            image.setAdjustViewBounds(true);
            image.setScaleType(ImageView.ScaleType.CENTER_CROP);
    

    And then there is no need to call fit or centerCrop while setting image using Picasso.


    Use centerCrop() for the imageView and it is available as a Picasso function.