You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DraggableUtils.makeDraggable(button, Draggable.STICKY.AXIS_X, true); // default is STICKY.NONE & animated true
150
+
DraggableUtils.makeDraggable(button, Draggable.STICKY.AXIS_X, false) // set sticky axis to x & animation to false
151
+
DraggableUtils.makeDraggable(button, Draggable.STICKY.AXIS_XY) // set sticky axis to xy
152
+
DraggableUtils.makeDraggable(button) // all default
116
153
117
154
// First param is the view
118
155
119
-
// Second param is the axis:
156
+
// Second param is the axis (optional)
120
157
// - Draggable.STICKY.AXIS_X
121
158
// - Draggable.STICKY.AXIS_Y
122
159
// - Draggable.STICKY.AXIS_XY
123
-
// - Draggable.STICKY.NONE
160
+
// - Draggable.STICKY.NONE (default)
161
+
162
+
// Third param is animation flag (optional)
163
+
// - true or false (default is true)
164
+
// *Sticky.NONE doesn't get affected by this flag
124
165
125
-
//Third param is animation toggle
126
-
// - true or false
166
+
//Fourth param is listener (optional)
167
+
// - DraggableListener implementation (default is null)
127
168
```
128
169
170
+
#### DraggableListener
171
+
There's an interface `DraggableListener` to listen to the `View` while being dragged / moved
172
+
173
+
```kotlin
174
+
interfaceDraggableListener {
175
+
funonViewMove(view:View)
176
+
}
177
+
```
178
+
Just pass the implementation of the interface to `makeDraggable` method
179
+
180
+
```kotlin
181
+
someView.makeDraggable(object:DraggableListener{
182
+
overridefunonViewMove(view:View){
183
+
// Do something, get coordinates of view, etc
184
+
}
185
+
})
186
+
187
+
// *Java counterpart must supply all 3 other params to use the listener
188
+
```
129
189
130
190
Check example module [kotlin](https://github.com/hyuwah/DraggableView/blob/master/example/src/main/java/io/github/hyuwah/draggableview/MainActivity.kt), [java](https://github.com/hyuwah/DraggableView/blob/master/example/src/main/java/io/github/hyuwah/draggableview/JavaMainActivity.java) for actual implementation
0 commit comments