Created
August 15, 2017 11:53
-
-
Save sagar-viradiya/16bd9079ba3e3d7172136f97e296b6a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun setupOnTouchListener() { | |
... | |
android_bot.setOnTouchListener { view, motionEvent -> | |
if(motionEvent.action == MotionEvent.ACTION_MOVE) { | |
val deltaX = motionEvent.rawX - lastX | |
val deltaY = motionEvent.rawY - lastY | |
view.translationX = deltaX + view.translationX | |
view.translationY = deltaY + view.translationY | |
firstSpringAnimationX.animateToFinalPosition(view.translationX) | |
firstSpringAnimationY.animateToFinalPosition(view.translationY) | |
} | |
lastX = motionEvent.rawX | |
lastY = motionEvent.rawY | |
return@setOnTouchListener true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment