Search code examples
androiddrag-and-dropontouchlistenerontouch

Drag & Drop OnTouch irregular shaped images


I am working on a simple app, which will allow moving one ImageView & dropping it on another ImageView. I am having problems with how onTouch works. It seems that it always takes rectangular input.

Let's say I have a shape like that: Link

All small dots represent places which will trigger onTouch. But only green ones should... So in other words, I do not want Drag to be triggered when I am touching transparent part of the image.

Is this possible?

BR, Kuba


Solution

  • If anyone will stumble upon this question, here is an answer: You must extend the DragShadowBuilder class to achieve that. More details in below question:

    Set custom anchor when dragging a View