List of usage examples for android.animation Keyframe setInterpolator
public void setInterpolator(TimeInterpolator interpolator)
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
private static Keyframe loadKeyframe(Context context, Resources res, Theme theme, AttributeSet attrs, int valueType, XmlPullParser parser) throws XmlPullParserException, IOException { TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_KEYFRAME); Keyframe keyframe = null; float fraction = TypedArrayUtils.getNamedFloat(a, parser, "fraction", AndroidResources.STYLEABLE_KEYFRAME_FRACTION, -1); TypedValue keyframeValue = TypedArrayUtils.peekNamedValue(a, parser, "value", AndroidResources.STYLEABLE_KEYFRAME_VALUE); boolean hasValue = (keyframeValue != null); if (valueType == VALUE_TYPE_UNDEFINED) { // When no value type is provided, check whether it's a color type first. // If not, fall back to default value type (i.e. float type). if (hasValue && isColorType(keyframeValue.type)) { valueType = VALUE_TYPE_COLOR; } else {/* w w w. j a v a2 s . com*/ valueType = VALUE_TYPE_FLOAT; } } if (hasValue) { switch (valueType) { case VALUE_TYPE_FLOAT: float value = TypedArrayUtils.getNamedFloat(a, parser, "value", AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0); keyframe = Keyframe.ofFloat(fraction, value); break; case VALUE_TYPE_COLOR: case VALUE_TYPE_INT: int intValue = TypedArrayUtils.getNamedInt(a, parser, "value", AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0); keyframe = Keyframe.ofInt(fraction, intValue); break; } } else { keyframe = (valueType == VALUE_TYPE_FLOAT) ? Keyframe.ofFloat(fraction) : Keyframe.ofInt(fraction); } final int resID = TypedArrayUtils.getNamedResourceId(a, parser, "interpolator", AndroidResources.STYLEABLE_KEYFRAME_INTERPOLATOR, 0); if (resID > 0) { final Interpolator interpolator = AnimationUtilsCompat.loadInterpolator(context, resID); keyframe.setInterpolator(interpolator); } a.recycle(); return keyframe; }