I was working on animated effect on android, I would like to know if there's any other way to gradually increase/decrease the animation speed?
Is it possible to specify like first 3 second rate of change was slow, and the rest goes fast?
使用插值器。对于您的情况,我会推荐AccelerateDecelerateInterpolator
Animation anim = AnimationUtils.loadAnimation(this, R.anim.your_animation);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
image.startAnimation(anim);
至于插值器,你可以自己构建!
public class MyInterpolator extends Interpolator {
public MyInterpolator(int valueCount) {
super(valueCount);
}
public float getInterpolation (float input) {
return (float)(Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
}
}
使用Wolfram Alpha,您可以使用参数。