Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jani
Created August 29, 2016 10:24
Show Gist options
  • Select an option

  • Save vaibhav-jani/2b5ca7fb0eebb7e0412ba3b7d635f10f to your computer and use it in GitHub Desktop.

Select an option

Save vaibhav-jani/2b5ca7fb0eebb7e0412ba3b7d635f10f to your computer and use it in GitHub Desktop.
Animate from one position to another
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