I am working on a UI where I need to drag a circular view vertically to a specific circle and when I drag it successfully I need to call a method in Android Kotlin
I created a drag listener but I can drag it all over the screen I don't wanna allow the view to move horizontally.
Related
Currently I'm working with tablet Android development. I want to drag a view from fragment A to fragment B, but the dragshadow will move from the destination to original position for the first time. Is there anyway to control the visibility of drag shadow in runtime?
You can disable drag shadow using following property in your View Pager.
android:overScrollMode="never"
I am trying to create 2d scrollview which can scroll in any direction and i have found the library for that.
But now i want to animate the items which are inside that view, like when any item is going outside then start shrinking (when going outside from any direction) and when coming inside the screen then animate to original size.
Thanks
I just want to know how to drag two views at the same time
first view is its original image view
Second one is its shadow
I am using dragShadow builder to build a drag shadow but when I drag a view using touchlistner it is only drag shadow of my main view and the main view is stick on their position ..
so my question is Is there any solution to enable drag both view simultaneously?
thank you for any kind of suggestion..
attach a picture
Wrap both ImageView and shadow in ViewGroup, for example, FrameLayout, and drag FrameLayout instead of ImageView.
Trying to create an application where a user drags a view (button/imageView) from a parent layout on top of another layout (probably a framelayout) in a single activity and have it stick to where i dragged it (kind of like a sticker).
The user could repeat this process until the framelayout is filled.
Currently looking at handling onDrag events and on ActionDrop just add a copy of the view being dragged to the new container. Kind of like this except without the removeView method.
Is there a better way? How would i do it if i wanted to place the view being dragged exactly on the same position ontop of the framelayout.
I have a viewgroup with textviews that are added dynamically into the viewgroup. How would I add the ability to drag and drop a textview between other textviews.
Is there a way to detect what view you have dropped it over.
If it makes it easier the textviews could be buttons.
On API 11 and up, you can use the built in functionality:
https://developer.android.com/guide/topics/ui/drag-drop.html
On previous versions, you can also do it by hand:
In theory, you have to add an onTouchListener for your views, which on action down saves the touch position relative to the view position.
Then, on receiving a touch move event, you set the position of the view to reflect that.
On receiving up event, the user has dropped the view, you check the current coordinates and compare them to the other views, if it is before another view, you move that view up and set the position of the moved view to be in line with the others again.
You can limit the dragging to only x/only y by only changing those values.