AccelerateDecelerate:
y = cos((t+1)π)/2+0.5
可让动画看起来较平顺,系统默认的interpolator也是AcceletateDecelerate
Demo:
Source:
public class AccelerateDecelerateInterpolator extends BaseInterpolator implements NativeInterpolatorFactory {
public AccelerateDecelerateInterpolator() {
}
@SuppressWarnings({"UnusedDeclaration"})
public AccelerateDecelerateInterpolator(Context context, AttributeSet attrs) {
}
public float getInterpolation(float input) {
return (float)(Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
// y = cos((t + 1)Math.PI)/2 + 0.5
}
@Override
public long createNativeInterpolator() {
return NativeInterpolatorFactoryHelper.createAccelerateDecelerateInterpolator();
}
}
原文:大专栏 Android animation interpolator: AcceletateDecelerate
原文地址:https://www.cnblogs.com/petewell/p/11457901.html
时间: 2024-11-13 06:43:29