本文介绍了Android - 限制拖放到边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android上拖放的默认行为显然允许在屏幕上的任何位置拖动DragShadow。



我想限制它的区域可以拖动到指定的边界框或特定视图的边界。



我看到我可以使用onInterceptTouchEvent来监视拖动位置,但是没有任何方式修改拖动位置。



有没有人成功完成了?

编辑:
由于我在这里没有任何答案,从未找到任何其他合适的答案,我写了我自己的实现。它不使用拖放api,它会模拟它。
请参阅

解决方案

由于我没有找到任何答案,从未找到任何其他合适的答案,我写了我自己的实现。它不使用拖放api,它会模拟它。请参阅


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

解决方案

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

这篇关于Android - 限制拖放到边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:06