Reputation: 1542
Is there documentation or an API that allows for an object to be flicked in a certain direction, such as a button? I've tried using 'drag & drop' to try and emulate this feature but not with the same results.
Here is an example: http://youtu.be/J-83lssy5kA?t=1m47s
Basically, you can see the guy flick the chat-head towards the close icon to close the chat. The same features are found in android launchers where you can flick to remove an icon fromthe home screen. Are those gestures custom built or is it an API, thanks.
Upvotes: 1
Views: 464
Reputation: 36
Yes I noticed this. I recently tried to find a coding for the same but never could and lost interest. But this is what I feel is the solution:- In a quick time interval find 2 points cordinates of that flicking action( drag) Then project a third point according to the slope of this line equation. Keep updating the position of the view you flicked while you make it travel slowly from point2 to projected point3 via may be a slow loop or timer
For slope you have (y1-y2)/(x1-x2)
Upvotes: 0
Reputation: 24998
The flick
that you are talking about is called fling
officially. Yes, you can handle fling events using the Android API by having your activity implement the GestureDetector.OnGestureListener
interface. This interface will let you handle all the common gestures like scroll, long press, fling and so on. In your case, the onFling()
method will be called.
However, in your case you only want the fling gesture in which case you will have to subclass GestureDetector.SimpleOnGestureListener
and override methods selectively.
For more, please refer the docs: http://developer.android.com/training/gestures/detector.html
Upvotes: 1