Skip to content

Instantly share code, notes, and snippets.

@rahulmmohan
Last active April 20, 2017 15:28
float STIFFNESS = SpringForce.STIFFNESS_MEDIUM;
float DAMPING_RATIO = SpringForce.DAMPING_RATIO_HIGH_BOUNCY;
movingView = (ImageView)findViewById(R.id.imageButton);
movingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
xAnimation = createSpringAnimation(
movingView, SpringAnimation.X, movingView.getX(), STIFFNESS, DAMPING_RATIO);
yAnimation = createSpringAnimation(
movingView, SpringAnimation.Y, movingView.getY(), STIFFNESS, DAMPING_RATIO);
movingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment