com.nineoldandroids.animation.ObjectAnimator.ofPropertyValuesHolder()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.nineoldandroids.animation.ObjectAnimator.ofPropertyValuesHolder()方法的一些代码示例,展示了ObjectAnimator.ofPropertyValuesHolder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectAnimator.ofPropertyValuesHolder()方法的具体详情如下:
包路径:com.nineoldandroids.animation.ObjectAnimator
类名称:ObjectAnimator
方法名:ofPropertyValuesHolder

ObjectAnimator.ofPropertyValuesHolder介绍

[英]Constructs and returns an ObjectAnimator that animates between the sets of values specified in PropertyValueHolder objects. This variant should be used when animating several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows you to associate a set of animation values with a property name.
[中]构造并返回一个ObjectAnimator,在PropertyValueHolder对象中指定的值集之间设置动画。使用同一个ObjectAnimator同时设置多个属性的动画时,应使用此变体,因为PropertyValuesHolder允许您将一组动画值与属性名称关联。

代码示例

代码示例来源:origin: tomahawk-player/tomahawk-android

public void setupStationContainerAnimation() {
  Resources resources = TomahawkApp.getContext().getResources();
  int resolverIconSize = resources.getDimensionPixelSize(
      R.dimen.playback_panel_resolver_icon_size);
  int padding = resources.getDimensionPixelSize(
      R.dimen.padding_small);
  // Setup mStationContainer animation
  Keyframe kfX0 = Keyframe.ofFloat(0f,
      mStationContainer.getWidth() - resolverIconSize);
  Keyframe kfX1 = Keyframe.ofFloat(0.5f,
      Math.max(resolverIconSize + padding,
          mStationContainer.getWidth() / 2 - mStationContainerInner.getWidth() / 2));
  Keyframe kfX2 = Keyframe.ofFloat(1f,
      mStationContainer.getWidth() - resolverIconSize);
  PropertyValuesHolder pvhX = PropertyValuesHolder.ofKeyframe("x", kfX0, kfX1, kfX2);
  ValueAnimator animator = ObjectAnimator
      .ofPropertyValuesHolder(mStationContainerInner, pvhX).setDuration(20000);
  animator.setInterpolator(new LinearInterpolator());
  animator.setCurrentPlayTime(mLastPlayTime);
  if (mStationContainerAnimation != null) {
    mAnimators.remove(mStationContainerAnimation);
  }
  mStationContainerAnimation = animator;
  mAnimators.add(mStationContainerAnimation);
}

代码示例来源:origin: tomahawk-player/tomahawk-android

@Override
  public void run() {
    // get resources first
    Resources resources = TomahawkApp.getContext().getResources();
    int dropDownHeight = resources.getDimensionPixelSize(
        R.dimen.show_context_menu_icon_height);
    int actionBarHeight = resources.getDimensionPixelSize(
        R.dimen.abc_action_bar_default_height_material);
    int smallPadding = resources.getDimensionPixelSize(
        R.dimen.padding_small);
    int superLargePadding = resources.getDimensionPixelSize(
        R.dimen.padding_superlarge);
    // now calculate the animation goal and instantiate the animation
    int initialX = view.getWidth() / 2 - fancyDropDown.getWidth() / 2;
    int initialY = view.getHeight() / 2 - dropDownHeight / 2;
    PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", initialX,
        superLargePadding);
    PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", initialY,
        actionBarHeight + smallPadding);
    ValueAnimator animator = ObjectAnimator
        .ofPropertyValuesHolder(fancyDropDown, pvhX, pvhY)
        .setDuration(10000);
    animator.setInterpolator(new LinearInterpolator());
    addAnimator(ANIM_FANCYDROPDOWN_ID, animator);
    refreshAnimations();
  }
};

代码示例来源:origin: guohuanwen/AndroidLoadingAnimation

private AnimatorSet riseVA(float x, float y) {
  AnimatorSet animatorSet = new AnimatorSet();
  PropertyValuesHolder p1 = PropertyValuesHolder.ofFloat("translationX", x);
  PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("translationY", y);
  animatorSet.play(ObjectAnimator.ofPropertyValuesHolder(view, p1, p2));
  //setDuration在play后面设置
  animatorSet.setDuration(500);
  animatorSet.setInterpolator(new DecelerateInterpolator());
  return animatorSet;
}

代码示例来源:origin: guohuanwen/AndroidLoadingAnimation

private AnimatorSet dropVA(float x, float y) {
  AnimatorSet animatorSet = new AnimatorSet();
  PropertyValuesHolder p1 = PropertyValuesHolder.ofFloat("translationX", x);
  PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("translationY", y);
  animatorSet.play(ObjectAnimator.ofPropertyValuesHolder(view, p1, p2));
  //setDuration在play后面设置
  animatorSet.setDuration(duration);
  animatorSet.setInterpolator(new AccelerateInterpolator());
  return animatorSet;
}

代码示例来源:origin: tomahawk-player/tomahawk-android

PropertyValuesHolder.ofKeyframe("scaleX", kfScale0, kfScale1, kfScale2);
ValueAnimator animator = ObjectAnimator
    .ofPropertyValuesHolder(mTextViewContainer, pvhY,
        pvhScaleX, pvhScaleY).setDuration(20000);
animator.setInterpolator(new LinearInterpolator());
pvhY = PropertyValuesHolder.ofKeyframe("y", kfY0, kfY1, kfY2);
animator = ObjectAnimator
    .ofPropertyValuesHolder(mPanelContainer, pvhY).setDuration(20000);
animator.setInterpolator(new LinearInterpolator());
animator.setCurrentPlayTime(mLastPlayTime);
PropertyValuesHolder pvhBgAlpha = PropertyValuesHolder
    .ofKeyframe("alpha", kfBgAlpha0, kfBgAlpha1, kfBgAlpha2);
animator = ObjectAnimator.ofPropertyValuesHolder(mPanelContainer.getBackground(),
    pvhBgAlpha).setDuration(20000);
animator.setInterpolator(new LinearInterpolator());

代码示例来源:origin: henrichg/PhoneProfilesPlus

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(
      AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusDisappear, fadeOut).setDuration(
      duration);
  disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
  return disappearAnimator;
}

代码示例来源:origin: posm/OpenMapKitAndroid

ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(this, propertiesList.toArray(new PropertyValuesHolder[0]));

代码示例来源:origin: henrichg/PhoneProfilesPlus

/**
 * 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(
          AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(labelToAnimate) : labelToAnimate, scaleX,
          scaleY);
  pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
  return pulseAnimator;
}

代码示例来源:origin: henrichg/PhoneProfilesPlus

PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
    AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusReappear, fadeIn)
    .setDuration(totalDuration);

代码示例来源:origin: henrichg/PhoneProfilesPlus

PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
    AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusDisappear, fadeOut)
    .setDuration(duration);
PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
    AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusReappear, fadeIn)
    .setDuration(totalDuration);

相关文章