问题
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