2

I am trying to duplicate an IOS Animation in Android. To my understanding I need to create an Interpolator (the animation) and using functions, within the getInterpolation method, change the time (t) and return it to effect the timing of the animation. In this case the element is moving up the screen (and it is!).

I understand that t = 1 means the final resting place of the animation, and I can go beyond 1 to make it look like it moved too far.

This I have experimented with but I keep removing and retrying...currently I have it just doing a simple, move up the screen.

public class JumpInterpolator implements Interpolator {

boolean jumped = false;

public JumpInterpolator() {

}

public float getInterpolation(float t) {
    return t;
}

}

The animation I am trying to reproduce is...

UIView.animateWithDuration(0.3, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.4, options: UIViewAnimationOptions.CurveEaseIn | UIViewAnimationOptions.LayoutSubviews | UIViewAnimationOptions.BeginFromCurrentState , animations: {
            // other code
            }, completion: completion)

The code has the window go up from the bottom of the screen quickly, overshoots its final position, then bounces back.

I would appreciate some guidance as I believe I am lacking in understanding the IOS animation code, rather then the ability to reproduce it.

user
  • 86,916
  • 18
  • 197
  • 190
Travis Knight
  • 301
  • 1
  • 4
  • 18
  • A gif or video with the animation would be helpful for non ios developers. – user Aug 24 '15 at 06:10
  • see sources of `android.view.animation.OvershootInterpolator` f.ex. http://androidxref.com/5.1.1_r6/xref/frameworks/base/core/java/android/view/animation/OvershootInterpolator.java – pskink Aug 24 '15 at 06:27
  • @pskink Thank you for the link! I have it working like a charm now. Thanks again! – Travis Knight Aug 27 '15 at 11:57

0 Answers0