Created
August 29, 2016 10:24
-
-
Save vaibhav-jani/2b5ca7fb0eebb7e0412ba3b7d635f10f to your computer and use it in GitHub Desktop.
Animate from one position to another
This file contains hidden or 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
| int x = targetView.getTop() + targetView.getWidth() / 2; | |
| int y = targetView.getTop() + targetView.getHeight() / 2; | |
| int fromX = sourceView.getTop() + sourceView.getWidth() / 2; | |
| int fromY = sourceView.getTop() + sourceView.getHeight() / 2; | |
| final int dx = x - fromX; | |
| final int dy = y - fromY; | |
| sourceView.animate().setDuration(400).translationX(dx); | |
| sourceView.animate().setDuration(400).translationY(dy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment