@Override public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { return ObjectAnimator.ofPropertyValuesHolder( view, PropertyValuesHolder.ofFloat(View.ALPHA, 0f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f)); }
PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, null, getPathMotion().getPath( run.start.left + dx, run.end.left, run.end.top)); PropertyValuesHolder width = PropertyValuesHolder.ofInt( SwitchDrawable.WIDTH, run.start.width(), run.end.width()); PropertyValuesHolder height = PropertyValuesHolder.ofInt( SwitchDrawable.HEIGHT, run.start.height(), run.end.height()); PropertyValuesHolder progress = PropertyValuesHolder.ofFloat( SwitchDrawable.PROGRESS, 0f, 1f); Animator runAnim = ObjectAnimator.ofPropertyValuesHolder(
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
public void startCircleMajor(final Callback callback) { PropertyValuesHolder rp = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius); PropertyValuesHolder ap = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .15f), 0); ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(rp, ap, sp); va.setInterpolator(new AccelerateInterpolator(.4f)); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius = (float) animation.getAnimatedValue("radius"); circleAlpha = (float) animation.getAnimatedValue("alpha"); circleStroke = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va.setDuration(450); va.start(); }
/** * ObjectAnimator: You can also create multiple animations by PropertyValuesHolder. * <p> * ValueAnimator has the same method, but we don't use it that way. #ValueAnimator.ofPropertyValuesHolder()# * * @return */ public Animator getObjectAnimatorByPropertyValuesHolder() { PropertyValuesHolder bgColorAnimator = PropertyValuesHolder.ofObject("backgroundColor", new ArgbEvaluator(), 0xff009688, 0xff795548); PropertyValuesHolder rotationXAnimator = PropertyValuesHolder.ofFloat("rotationX", 0f, 360f); ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(mPuppet, bgColorAnimator, rotationXAnimator); objectAnimator.setDuration(3000); objectAnimator.setRepeatCount(1); objectAnimator.setRepeatMode(ValueAnimator.REVERSE); return objectAnimator; }
private PropertyValuesHolder createColorPropertyHolder(String propertyName, int startValue, int endValue) { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startValue, endValue); holder.setEvaluator(new IntEvaluator()); return holder; }
@NonNull public static <T> ObjectAnimator ofInt(@Nullable T target, @NonNull Property<T, Integer> xProperty, @NonNull Property<T, Integer> yProperty, @NonNull Path path) { int[] xValues = new int[NUM_POINTS]; int[] yValues = new int[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofInt(xProperty, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofInt(yProperty, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
BorderDrawable borderDrawable; if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) { holders.add(PropertyValuesHolder.ofObject( WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor))); } else if (target.getBackground() instanceof ColorDrawable) { holders.add(PropertyValuesHolder.ofObject( WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(),
public void startCircleMinor(final Callback callback) { PropertyValuesHolder rp2 = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius * .60f); PropertyValuesHolder ap2 = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp2 = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .06f), 0); ValueAnimator va2 = ValueAnimator.ofPropertyValuesHolder(rp2, ap2, sp2); va2.setInterpolator(new AccelerateInterpolator(.4f)); va2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius2 = (float) animation.getAnimatedValue("radius"); circleAlpha2 = (float) animation.getAnimatedValue("alpha"); circleStroke2 = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va2.setDuration(380); va2.start(); }
private PropertyValuesHolder createSlidePropertyHolder() { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(ANIMATION_COORDINATE, coordinateStart, coordinateEnd); holder.setEvaluator(new IntEvaluator()); return holder; }
@NonNull public static ObjectAnimator ofInt(@Nullable Object target, @NonNull String xPropertyName, @NonNull String yPropertyName, @NonNull Path path) { int[] xValues = new int[NUM_POINTS]; int[] yValues = new int[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofInt(xPropertyName, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofInt(yPropertyName, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
@Override public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { view.setAlpha(0f); view.setScaleX(0f); view.setScaleY(0f); return ObjectAnimator.ofPropertyValuesHolder( view, PropertyValuesHolder.ofFloat(View.ALPHA, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f)); }
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
PropertyValuesHolder createColorPropertyHolder(boolean isReverse) { String propertyName; int colorStart; int colorEnd; if (isReverse) { propertyName = ANIMATION_COLOR_REVERSE; colorStart = this.colorEnd; colorEnd = this.colorStart; } else { propertyName = ANIMATION_COLOR; colorStart = this.colorStart; colorEnd = this.colorEnd; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, colorStart, colorEnd); holder.setEvaluator(new ArgbEvaluator()); return holder; }
break; case MoveType.back: PropertyValuesHolder pvhX = PropertyValuesHolder.ofInt("x", mFloatView.getX(), mB.xOffset); PropertyValuesHolder pvhY = PropertyValuesHolder.ofInt("y", mFloatView.getY(), mB.yOffset); mAnimator = ObjectAnimator.ofPropertyValuesHolder(pvhX, pvhY); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { return ObjectAnimator.ofPropertyValuesHolder( endValues.view, PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f)); }
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; } }
@NonNull private PropertyValuesHolder createStrokePropertyHolder(boolean isReverse) { String propertyName; int startStrokeValue; int endStrokeValue; if (isReverse) { propertyName = ANIMATION_STROKE_REVERSE; startStrokeValue = radius; endStrokeValue = 0; } else { propertyName = ANIMATION_STROKE; startStrokeValue = 0; endStrokeValue = radius; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startStrokeValue, endStrokeValue); holder.setEvaluator(new IntEvaluator()); return holder; }
break; case MoveType.back: PropertyValuesHolder pvhX = PropertyValuesHolder.ofInt("x", mFloatView.getX(), mB.xOffset); PropertyValuesHolder pvhY = PropertyValuesHolder.ofInt("y", mFloatView.getY(), mB.yOffset); mAnimator = ObjectAnimator.ofPropertyValuesHolder(pvhX, pvhY); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { return ObjectAnimator.ofPropertyValuesHolder( endValues.view, PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f)); }