Drag and drop between two fragments

别说谁变了你拦得住时间么 提交于 2019-12-09 18:22:36

问题


I am working on drag and drop between two different fragments visible at same time on UI.

I want to drag view from one fragment into the other fragment. I am able to drag it between the fragment but what i am facing not good is that i can't listen onDrag on second fragment for the view of first fragment.

In Short the OnDragListener on second fragment should listen for the views dragged from first fragment.

I have searched alot on google and stackoverflow. Didn't find any answer.

Drag and Drop view between two Fragments

drag and drop between two fragments?

I somebody knows please share.


回答1:


Have you considered creating an overlaying View above both Fragments, which should not intercept touches, but as soon as you start dragging the view - a copy of it will be created in this overlay and follow the dragging? I can't see any other way of implementing this, since two Fragments have separate view hierarchies and the only way I can see is transfer the View through Activity's view hierarchy

BTW is there any way to avoid using of two Fragments? What kind of use case do you have?



来源:https://stackoverflow.com/questions/29825472/drag-and-drop-between-two-fragments

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