Android - Constrain Drag and Drop to a Bounding Box

♀尐吖头ヾ 提交于 2019-12-13 12:00:06

问题


The default behavior of drag and drop on Android apparently allows the DragShadow to be dragged anywhere on the screen.

I'd like to limit the area in which it can be dragged - either to a specified bounding box, or to a the bounds of a particular view.

I see that I can monitor the drag location with onInterceptTouchEvent, but I don't see any way to modify the drag location.

Has anyone done this successfully?

EDIT: Since I got no answers here, and never did find any other suitable answer, I wrote my own implementation. It doesn't use the drag-and-drop api, it simulates it instead. See https://github.com/rfreedman/android-constrained-drag-and-drop-view

来源:https://stackoverflow.com/questions/17111135/android-constrain-drag-and-drop-to-a-bounding-box

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