1

I am new to android.I have a RecyclerView which shows list of images from a json.I want to do showing image full screen when item from RecyclerView clicks.Also it should be able to zoom in and out.(Like gallery).Zooming functionalty is done using Photoview Library.But viewing full screen a item is not done.Adapter class code is attached below.Please anyone help me to do this.

 @Override
 public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    final MyHolder myHolder = (MyHolder) holder;
    DataFish current = data.get(position);

    // load image into imageview using glide
    Glide.with(context).load(current.flagimage)
            .placeholder(R.drawable.ic_launcher_background)
            .error(R.drawable.ic_launcher_background)
            .into(myHolder.imageView);
    myHolder.imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });


}

I want to add the code for view full screen in this onclick.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
anju.johnson
  • 41
  • 1
  • 9
  • First get the bitmap of the image when user click on the item and then on the next activity/or fragment where you want to show , then set that bitmap on the imageview . Hope you get the idea – Amit Ranjan May 02 '18 at 04:58
  • Can i show the imageview using dialog without moving to next fragment/activity? – anju.johnson May 02 '18 at 05:05
  • you can follow this link to get the dilog full screen :https://stackoverflow.com/questions/6329360/how-to-set-dialog-to-show-with-full-screen – Amit Ranjan May 02 '18 at 05:10

1 Answers1

6

follow this steps

create a new Activity like this and retrive url

LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/myImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:scaleType="fitXY" />

</LinearLayout>

Activity.java

public class MainActivity extends AppCompatActivity {


    ImageView myImage;
    String url = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        url = getIntent().getStringExtra("image_url");

        myImage = findViewById(R.id.myImage);
        Glide.with(this).load(url)
                .placeholder(R.drawable.ic_launcher_background)
                .error(R.drawable.ic_launcher_background)
                .into(myImage);
    }


}

When use click om recyclerview item than pass the url to that activity using intent

 myHolder.imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent= new Intent(context,MainActivity.this);
            intent.putExtra("image_url",current.flagimage);
            context.startActivity(intent);
        }
    });

you can use PhotoView for zooming ImageView

PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163