Emzor
Emzor

Reputation: 1368

How to make image in imageView selectable in android?

I know it is possible to make text in textView selectable (for copy and paste) using android:textIsSelectable="true".

I want to make image in imageView selectable (for copy and paste as shown in the image below). Does anyone have a clue?

enter image description here

Upvotes: 1

Views: 900

Answers (1)

Nelson Hoang
Nelson Hoang

Reputation: 413

The Android OS does not support this natively. You will have to register your ImageView with registerForContextMenu. More info about context menus here.

Then you can get the ImageView's bitmap by doing ((BitmapDrawable)yourImageView.getDrawable()).getBitmap();

See here for more information on copying the bitmap onto the clipboard.

As a final comment I will say most Android users, myself included, would not expect to be able to long tap an image to copy it onto their clipboard unless there was some indication that it was possible in your app.

Upvotes: 1

Related Questions