2

This is my ImageViewHolder that I have mentioned in my adapter class

public static class ImageTypeViewHolder extends RecyclerView.ViewHolder {
    TextView imageCard_Title,imageCard_Description;
    public ImageView imageCardView;

    public ImageTypeViewHolder(View itemView) {
        super(itemView);
        imageCard_Title=itemView.findViewById(R.id.imagecard_title);
        imageCard_Description=itemView.findViewById(R.id.imagecard_description);
        imageCardView=itemView.findViewById(R.id.imagecard_picture);
    }
}

This is the segment of code written in my onBindViewHolder

((ImageTypeViewHolder) viewHolder).imageCard_Title.setText(modelObject.getImageCardTitle());
((ImageTypeViewHolder) viewHolder).imageCard_Description.setText(modelObject.getImageCardDescription());
((ImageTypeViewHolder) viewHolder).imageCardView.setImageResource(modelObject.getImageCardUrl());

I want to create an option which creates a fullscreen view of the imageview which is a part of the RecyclerView item.

This is the code segment in the activity where i'm adding the imagecard element :

chatList.add(new OustChatModel(1,
            "Sample Image Card",
            R.drawable.app_icon,
            "sample description"));

I would like to know what do I do to add a operation that allows the imagecard view to open in a full screen view.

Thanks in advance

2 Answers2

1

Create full screen image Fragment or Activity and simply use shared element transition on click to get nice animated full screen image. It is easy to accomplish with Android SharedElementTransitions.

Please read : SharedElementTransition Guide

Antonis Radz
  • 3,036
  • 1
  • 16
  • 34
0

In the case of a custom adapter, where you populate your activity/fragment with multiple viewholders, you can make use of an interface to pass data from a fragment to activity.

I provided a interface in the adapter class with a method defined :

public interface onImageClick
{ void onClickImageView(Drawable image);}

Define an object of this interface in this adapter class

onImageClick mObject;

and also declare it in the constructor of the adapter class :

mObject = (onImageClick) this.mCtx;

Now, setup a OnClickListener in the onBindViewHolder()

((ImageTypeViewHolder) viewHolder).imageCardView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mObject.onClickImageView(((ImageTypeViewHolder) viewHolder).imageCardView.getDrawable());
                    }
                });

Write the interface method declared in the activity/fragment where you access Recycler view items :

@Override
public void onClickImageView(Drawable image) {
    //Your operation here
}