类android.animation.Keyframe源码实例Demo

下面列出了怎么用android.animation.Keyframe的API类实例代码及写法,或者点击链接到github查看源代码。

public ObjectAnimator getDisappearAnimator() {
  if (!mIsInitialized || !mDrawValuesReady) {
    Log.e(TAG, "RadialSelectorView was not ready for animation.");
    return null;
  }

  Keyframe kf0, kf1, kf2;
  float midwayPoint = 0.2f;
  int duration = 500;

  kf0 = Keyframe.ofFloat(0f, 1);
  kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
  kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
  PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
    "animationRadiusMultiplier", kf0, kf1, kf2);

  kf0 = Keyframe.ofFloat(0f, 1f);
  kf1 = Keyframe.ofFloat(1f, 0f);
  PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

  ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
    this, radiusDisappear, fadeOut).setDuration(duration);
  disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

  return disappearAnimator;
}
 
源代码2 项目: PersianDateRangePicker   文件: Utils.java
/**
 * 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;
}
 
源代码3 项目: customview-samples   文件: CircleAnimView.java
public void startAnim(){
    if(mValueAnimator!=null&&mValueAnimator.isRunning()){
        return;
    }
    Keyframe k1 = Keyframe.ofFloat(0,mMinSize/2);
    Keyframe k2 = Keyframe.ofFloat(0.5f,mMinSize/4);
    Keyframe k3 = Keyframe.ofFloat(1,mMinSize/2);
    PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("scale",k1,k2,k3);
    mValueAnimator = ValueAnimator.ofPropertyValuesHolder(propertyValuesHolder);
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRadius = (float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mValueAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mValueAnimator.setDuration(2000);
    mValueAnimator.start();
}
 
源代码4 项目: AssistantBySDK   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码5 项目: AssistantBySDK   文件: Utils.java
/**
 * 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;
}
 
private PropertyValuesHolder getRotationValuesHolder() {
    Keyframe frame0 = Keyframe.ofFloat(0f, 0);
    Keyframe frame1 = Keyframe.ofFloat(0.1f, -10f);
    Keyframe frame2 = Keyframe.ofFloat(0.2f, 10f);
    Keyframe frame3 = Keyframe.ofFloat(0.3f, -10f);
    Keyframe frame4 = Keyframe.ofFloat(0.4f, 10f);
    Keyframe frame5 = Keyframe.ofFloat(0.5f, -10f);
    Keyframe frame6 = Keyframe.ofFloat(0.6f, 10f);
    Keyframe frame7 = Keyframe.ofFloat(0.7f, -10f);
    Keyframe frame8 = Keyframe.ofFloat(0.8f, 10f);
    Keyframe frame9 = Keyframe.ofFloat(0.9f, -10f);
    Keyframe frame10 = Keyframe.ofFloat(1, 0);

    return PropertyValuesHolder.ofKeyframe("rotation",
            frame0, frame1, frame2, frame3, frame4,
            frame5, frame6, frame7, frame8, frame9, frame10);
}
 
private PropertyValuesHolder getScaleXValuesHolder() {
    Keyframe frame0 = Keyframe.ofFloat(0f, 1);
    Keyframe frame1 = Keyframe.ofFloat(0.1f, 1.1f);
    Keyframe frame2 = Keyframe.ofFloat(0.2f, 1.1f);
    Keyframe frame3 = Keyframe.ofFloat(0.3f, 1.1f);
    Keyframe frame4 = Keyframe.ofFloat(0.4f, 1.1f);
    Keyframe frame5 = Keyframe.ofFloat(0.5f, 1.1f);
    Keyframe frame6 = Keyframe.ofFloat(0.6f, 1.1f);
    Keyframe frame7 = Keyframe.ofFloat(0.7f, 1.1f);
    Keyframe frame8 = Keyframe.ofFloat(0.8f, 1.1f);
    Keyframe frame9 = Keyframe.ofFloat(0.9f, 1.1f);
    Keyframe frame10 = Keyframe.ofFloat(1, 1);

    return PropertyValuesHolder.ofKeyframe("scaleX",
            frame0, frame1, frame2, frame3, frame4,
            frame5, frame6, frame7, frame8, frame9, frame10);
}
 
private PropertyValuesHolder getScaleYValuesHolder() {
    Keyframe frame0 = Keyframe.ofFloat(0f, 1);
    Keyframe frame1 = Keyframe.ofFloat(0.1f, 1.1f);
    Keyframe frame2 = Keyframe.ofFloat(0.2f, 1.1f);
    Keyframe frame3 = Keyframe.ofFloat(0.3f, 1.1f);
    Keyframe frame4 = Keyframe.ofFloat(0.4f, 1.1f);
    Keyframe frame5 = Keyframe.ofFloat(0.5f, 1.1f);
    Keyframe frame6 = Keyframe.ofFloat(0.6f, 1.1f);
    Keyframe frame7 = Keyframe.ofFloat(0.7f, 1.1f);
    Keyframe frame8 = Keyframe.ofFloat(0.8f, 1.1f);
    Keyframe frame9 = Keyframe.ofFloat(0.9f, 1.1f);
    Keyframe frame10 = Keyframe.ofFloat(1, 1);

    return PropertyValuesHolder.ofKeyframe("scaleY",
            frame0, frame1, frame2, frame3, frame4,
            frame5, frame6, frame7, frame8, frame9, frame10);
}
 
源代码9 项目: narrate-android   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码10 项目: narrate-android   文件: Utils.java
/**
 * 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;
}
 
源代码11 项目: ClockPlus   文件: Utils.java
/**
 * 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;
}
 
源代码12 项目: BottomSheetPickers   文件: Utils.java
/**
 * 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;
}
 
源代码13 项目: Blackbulb   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码14 项目: Blackbulb   文件: Utils.java
/**
 * 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;
}
 
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码16 项目: date_picker_converter   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码17 项目: date_picker_converter   文件: Utils.java
/**
 * 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;
}
 
源代码18 项目: SublimePicker   文件: RadialTimePickerView.java
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
源代码19 项目: auid2   文件: MainActivity.java
@Override
public void onClick(final View button) {
    button.setEnabled(false);
    View icon = findViewById(R.id.icon);

    Keyframe keyframe1 = Keyframe.ofFloat(0f, 0f);
    Keyframe keyframe2 = Keyframe.ofFloat(.4f, 90f);
    Keyframe keyframe3 = Keyframe.ofFloat(.6f, 90f);
    Keyframe keyframe4 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("rotation", keyframe1, keyframe2, keyframe3, keyframe4);
    ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(icon, propertyValuesHolder);
    rotationAnim.setDuration(5000);
    rotationAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            button.setEnabled(true);
        }
    });
    rotationAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    rotationAnim.start();
}
 
源代码20 项目: CameraColorPicker   文件: Views.java
/**
 * Credit goes to Cyril Mottier.
 * https://plus.google.com/+CyrilMottier/posts/FABaJhRMCuy
 *
 * @param view the {@link View} to animate.
 * @return an {@link ObjectAnimator} that will play a 'nope' animation.
 */
public static ObjectAnimator nopeAnimation(View view, int delta) {
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
源代码22 项目: AlarmOn   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码23 项目: AlarmOn   文件: Utils.java
/**
 * 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;
}
 
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码25 项目: MaterialDateTimePicker   文件: Utils.java
/**
 * 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;
}
 
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码27 项目: MaterialDateRangePicker   文件: Utils.java
/**
 * 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;
}
 
源代码28 项目: UltimateAndroid   文件: AnimationUtils.java
/**
 * Shake the view from left to right
 *
 * @param view
 * @return
 */
public static ObjectAnimator leftRightShake(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
源代码29 项目: UltimateAndroid   文件: AnimationUtils.java
public static ObjectAnimator nope(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
源代码30 项目: UltimateAndroid   文件: AnimationUtils.java
/**
 * Shake the view from left to right
 *
 * @param view
 * @return
 */
public static ObjectAnimator leftRightShake(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}