Ebad Saghar
Ebad Saghar

Reputation: 1127

How to view an ImageView when clicked in Android

I have multiple ImageViews inside a Fragment. Each `ImageView is used as a thumbnail. I want to be able to "view" the image when the user clicks on the thumbnail.

How is effect achieved? Would I use an intent and open the device's gallery to view it? I'm not sure on what approach to take (let alone not knowing any approaches at all).

Note: the images in the thumbnails are from a Parse database. So I can not use a URI to gallery intent.

Upvotes: 0

Views: 323

Answers (2)

RajSharma
RajSharma

Reputation: 1971

There are multiple ways.

  1. You can launch an activity that as an imageview inside it.
  2. Display a DialogFragment or any other fragment or dialog.

This totally depends upon the way how you want to display your image.

For ex- take example of wahts app . They have thumbnail. Wehn you click on the image thumbnail, they dipslay it inside a dialogFragment.

I hope it would help you.

I think this link might help you... This has iamgeview defined in the layour for DialogFragment.

Upvotes: 1

pgiitu
pgiitu

Reputation: 1669

You can launch a Dialog Fragment or Simple Fragment which has an ImageView and show the image there once the user taps on the thumbnail.

You can use ParseImageView to load and show the image.

Also if you want the user to be able to swipe left and right to different images and also want to support zoom gesture you can implement it via a ViewPager with TouchImageView.

Checkout: https://github.com/MikeOrtiz/TouchImageView

Upvotes: 1

Related Questions