嵌套片段的 ListViewDragging 问题
ListViewDragging issue on nested fragment
我正在使用 DevBytes 的 ListViewDraggingAnimation。
我使用了两次:在一个 Fragment 中,以及在应用程序另一部分的嵌套 Fragment 中。但它显示完全相同的东西。
在 Lollipop 5.1 (Nexus 6) 上它工作得很好。
在我的另一台测试设备 Galaxy S3 4.1.1 上,情况有所不同:
非嵌套 Fragment 工作正常,但在嵌套 Fragment 中,当我想拖动一个项目时,它开始拖动,然后在稍微移动之后(不足以与其他单元格切换)它会回到以前的位置。
为了兼容 API 14,我正在使用支持片段(嵌套的经典片段在 api 17 以下不起作用)
我搜索了解决方案,但没有找到任何东西。有人已经面对这个问题并解决了吗?
有什么提示吗?谢谢:)
好的,认真看了代码和日志,终于找到解决办法了!
问题是 motionEvent 被扔给父视图取消了。
因此,在 DynamicListView
中,我通过在 MotionEvent.ACTION_MOVE
中添加 this.requestDisallowInterceptTouchEvent(true);
来修改 onTouchEvent
函数。
来自文档:
requestDisallowInterceptTouchEvent (boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
希望这对其他人有帮助:)
我正在使用 DevBytes 的 ListViewDraggingAnimation。
我使用了两次:在一个 Fragment 中,以及在应用程序另一部分的嵌套 Fragment 中。但它显示完全相同的东西。
在 Lollipop 5.1 (Nexus 6) 上它工作得很好。 在我的另一台测试设备 Galaxy S3 4.1.1 上,情况有所不同: 非嵌套 Fragment 工作正常,但在嵌套 Fragment 中,当我想拖动一个项目时,它开始拖动,然后在稍微移动之后(不足以与其他单元格切换)它会回到以前的位置。
为了兼容 API 14,我正在使用支持片段(嵌套的经典片段在 api 17 以下不起作用)
我搜索了解决方案,但没有找到任何东西。有人已经面对这个问题并解决了吗?
有什么提示吗?谢谢:)
好的,认真看了代码和日志,终于找到解决办法了!
问题是 motionEvent 被扔给父视图取消了。
因此,在 DynamicListView
中,我通过在 MotionEvent.ACTION_MOVE
中添加 this.requestDisallowInterceptTouchEvent(true);
来修改 onTouchEvent
函数。
来自文档:
requestDisallowInterceptTouchEvent (boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
希望这对其他人有帮助:)