Android - combine swipe and pinch-to-zoom

孤街醉人 提交于 2019-11-27 17:02:51

问题


  • We have the Gallery, which support swiping.
  • We also have 3rd-party components that support pinch-to-zoom on ImageView, such as ImageViewTouch in ImageViewZoom.

Now I would like to combine them both.

The problem is that the swipe events get consumed by the ImageViewTouch and missed by the Gallery.

How can consume events by both components?

That would solve my problem, because, eventually, after a few events, each component will know how to react accordingly. For example, if the first event is ACTION_DOWN, it can be part of a pinch-to-zoom or part of a swipe. Both components (Gallery and ImageViewTouch) should consume it in order to know what to do in following events.


回答1:


I combined both components by changing some code in ImageViewZoom. The change was for the events to return a value if they were consumed by the ImageViewTouch. If so, than the event should not be passed to the gallery. If the event is not consumed by the ImageView, than the gallery should consume it (if it can).

There are still some small issues, but it's functional. Hopefully other people in the community can help.

Here's the fork on github: https://github.com/kilaka/ImageViewZoom

Thanks.



来源:https://stackoverflow.com/questions/11672210/android-combine-swipe-and-pinch-to-zoom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!