/** * Abstraction for an Animation that can be applied to Views, Surfaces, or * other objects. */ publicabstractclassAnimationimplementsCloneable { /** * Creates a new animation with a duration of 0ms, the default interpolator, with * fillBefore set to true and fillAfter set to false */ publicAnimation() { ensureInterpolator(); }
/** * Defines the transformation to be applied at * one point in time of an Animation. * */ publicclassTransformation { protected Matrix mMatrix; protectedfloat mAlpha;
/** * Creates a new transformation with alpha = 1 and the identity matrix. */ publicTransformation() { clear(); }
/** * A time interpolator defines the rate of change of an animation. This allows animations * to have non-linear motion, such as acceleration and deceleration. */ publicinterfaceTimeInterpolator { floatgetInterpolation(float input); }
/** * An interpolator defines the rate of change of an animation. This allows * the basic animation effects (alpha, scale, translate, rotate) to be * accelerated, decelerated, repeated, etc. */ publicinterfaceInterpolatorextendsTimeInterpolator { // A new interface, TimeInterpolator, was introduced for the new android.animation // package. This older Interpolator interface extends TimeInterpolator so that users of // the new Animator-based animations can use either the old Interpolator implementations or // new classes that implement TimeInterpolator directly. }
/** * Interface for use with the ValueAnimator#setEvaluator(TypeEvaluator) function. Evaluators * allow developers to create animations on arbitrary property types, by allowing them to supply * custom evaluators for types that are not automatically understood and used by the animation * system. */ publicinterfaceTypeEvaluator<T> { public T evaluate(float fraction, T startValue, T endValue);
}
IntEvaluator
1 2 3 4 5 6 7 8 9
/** * This evaluator can be used to perform type interpolation between <code>int</code> values. */ publicclassIntEvaluatorimplementsTypeEvaluator<Integer> { public Integer evaluate(float fraction, Integer startValue, Integer endValue) { intstartInt= startValue; return (int)(startInt + fraction * (endValue - startInt)); } }
/** * This evaluator can be used to perform type interpolation between integer * values that represent ARGB colors. */ publicclassArgbEvaluatorimplementsTypeEvaluator { privatestaticfinalArgbEvaluatorsInstance=newArgbEvaluator();
// compute the interpolated color in linear space floata= startA + fraction * (endA - startA); floatr= startR + fraction * (endR - startR); floatg= startG + fraction * (endG - startG); floatb= startB + fraction * (endB - startB);
// convert back to sRGB in the [0..255] range a = a * 255.0f; r = (float) Math.pow(r, 1.0 / 2.2) * 255.0f; g = (float) Math.pow(g, 1.0 / 2.2) * 255.0f; b = (float) Math.pow(b, 1.0 / 2.2) * 255.0f;
/** * This evaluator can be used to perform type interpolation between <code>PointF</code> values. */ publicclassPointFEvaluatorimplementsTypeEvaluator<PointF> { private PointF mPoint;