android.animation.ObjectAnimator.setInterpolator()方法的使用及代码示例

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

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

ObjectAnimator.setInterpolator介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 500); // see this max value coming back here, we animale towards that value
animation.setDuration (5000); //in milliseconds
animation.setInterpolator (new DecelerateInterpolator ());
animation.start ();

代码示例来源:origin: stackoverflow.com

if(android.os.Build.VERSION.SDK_INT >= 11){
  // will update the "progress" propriety of seekbar until it reaches progress
  ObjectAnimator animation = ObjectAnimator.ofInt(seekbar, "progress", progress); 
  animation.setDuration(500); // 0.5 second
  animation.setInterpolator(new DecelerateInterpolator());
  animation.start();
}
else 
  seekbar.setProgress(progress); // no animation on Gingerbread or lower

代码示例来源:origin: PhilJay/MPAndroidChart

@RequiresApi(11)
private ObjectAnimator yAnimator(int duration, EasingFunction easing) {
  ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
  animatorY.setInterpolator(easing);
  animatorY.setDuration(duration);
  return animatorY;
}

代码示例来源:origin: PhilJay/MPAndroidChart

@RequiresApi(11)
private ObjectAnimator xAnimator(int duration, EasingFunction easing) {
  ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
  animatorX.setInterpolator(easing);
  animatorX.setDuration(duration);
  return animatorX;
}

代码示例来源:origin: frogermcs/InstaMaterial

private void setupSimulateProgressAnimator() {
  simulateProgressAnimator = ObjectAnimator.ofFloat(this, "currentProgress", 0, 100).setDuration(2000);
  simulateProgressAnimator.setInterpolator(new AccelerateInterpolator());
  simulateProgressAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_DONE_STARTED);
    }
  });
}

代码示例来源:origin: florent37/ExpectAnim

public void reset() {
  final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "percent", 1f, 0f);
  objectAnimator.setDuration(duration);
  if (interpolator != null) {
    objectAnimator.setInterpolator(interpolator);
  }
  objectAnimator.start();
}

代码示例来源:origin: frogermcs/InstaMaterial

private void setupDoneAnimators() {
  doneBgAnimator = ObjectAnimator.ofFloat(this, "currentDoneBgOffset", MAX_DONE_BG_OFFSET, 0).setDuration(300);
  doneBgAnimator.setInterpolator(new DecelerateInterpolator());
  checkmarkAnimator = ObjectAnimator.ofFloat(this, "currentCheckmarkOffset", MAX_DONE_IMG_OFFSET, 0).setDuration(300);
  checkmarkAnimator.setInterpolator(new OvershootInterpolator());
  checkmarkAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_FINISHED);
    }
  });
}

代码示例来源:origin: TakuSemba/Spotlight

void finishSpotlight(long duration, TimeInterpolator animation,
  AbstractAnimatorListener listener) {
 ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f);
 objectAnimator.setDuration(duration);
 objectAnimator.setInterpolator(animation);
 objectAnimator.addListener(listener);
 objectAnimator.start();
}

代码示例来源:origin: aa112901/remusic

public void initRotateAnimation(float start) {
  mObjectAnimator = ObjectAnimator.ofFloat(this, "rotation", start, 360f + start);
  mObjectAnimator.setDuration(DEFAULT_DURATION);
  mObjectAnimator.setInterpolator(new LinearInterpolator());
  mObjectAnimator.setRepeatCount(ObjectAnimator.INFINITE);
}

代码示例来源:origin: ZieIony/Carbon

@Override
protected Animator createSoftwareEnter(boolean fast) {
  // Linear enter based on current opacity.
  final int maxDuration = fast ? OPACITY_ENTER_DURATION_FAST : OPACITY_ENTER_DURATION;
  final int duration = (int) ((1 - mOpacity) * maxDuration);
  final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 1);
  AnimatorsCompat.setAutoCancel(opacity);
  //opacity.setAutoCancel(true);
  opacity.setDuration(duration);
  opacity.setInterpolator(LINEAR_INTERPOLATOR);
  return opacity;
}

代码示例来源:origin: EverythingMe/overscroll-decor

protected ObjectAnimator createSlowdownAnimator(View view, int slowdownDuration, float slowdownEndOffset) {
  ObjectAnimator slowdownAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, slowdownEndOffset);
  slowdownAnim.setDuration(slowdownDuration);
  slowdownAnim.setInterpolator(mBounceBackInterpolator);
  slowdownAnim.addUpdateListener(this);
  return slowdownAnim;
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
   * Applys a spin animation to the Chart.
   *
   * @param durationmillis
   * @param fromangle
   * @param toangle
   */
  @SuppressLint("NewApi")
  public void spin(int durationmillis, float fromangle, float toangle, EasingFunction easing) {

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
        toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(easing);

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        postInvalidate();
      }
    });
    spinAnimator.start();
  }
}

代码示例来源:origin: EverythingMe/overscroll-decor

protected ObjectAnimator createBounceBackAnimator(float startOffset) {
    final View view = mViewAdapter.getView();
    // Duration is proportional to the view's size.
    float bounceBackDuration = (Math.abs(startOffset) / mAnimAttributes.mMaxOffset) * MAX_BOUNCE_BACK_DURATION_MS;
    ObjectAnimator bounceBackAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, mStartAttr.mAbsOffset);
    bounceBackAnim.setDuration(Math.max((int) bounceBackDuration, MIN_BOUNCE_BACK_DURATION_MS));
    bounceBackAnim.setInterpolator(mBounceBackInterpolator);
    bounceBackAnim.addUpdateListener(this);
    return bounceBackAnim;
  }
}

代码示例来源:origin: hitherejoe/animate

private void resizeViewProperty(Property<View, Float> property,
                float targetScale, int durationOffset) {
  ObjectAnimator animator =
      ObjectAnimator.ofFloat(this, property, 1f, targetScale);
  animator.setInterpolator(new LinearOutSlowInInterpolator());
  animator.setStartDelay(DELAY_COLOR_CHANGE + durationOffset);
  animator.start();
}

代码示例来源:origin: balysv/material-ripple

private void startHover() {
  if (eventCancelled) return;
  if (hoverAnimator != null) {
    hoverAnimator.cancel();
  }
  final float radius = (float) (Math.sqrt(Math.pow(getWidth(), 2) + Math.pow(getHeight(), 2)) * 1.2f);
  hoverAnimator = ObjectAnimator.ofFloat(this, radiusProperty, rippleDiameter, radius)
    .setDuration(HOVER_DURATION);
  hoverAnimator.setInterpolator(new LinearInterpolator());
  hoverAnimator.start();
}

代码示例来源:origin: xfumihiro/ViewInspector

@Override protected void onAttachedToWindow() {
 super.onAttachedToWindow();
 LinearLayout progressbarLayout = (LinearLayout) findViewById(R.id.progressbar_layout);
 progressbarLayout.setTranslationY(-mLayoutHeight);
 progressbarLayout.setVisibility(VISIBLE);
 ObjectAnimator animator =
   ObjectAnimator.ofFloat(progressbarLayout, "translationY", -mLayoutHeight, 0);
 animator.setInterpolator(new DecelerateInterpolator());
 animator.setDuration(500);
 animator.start();
}

代码示例来源:origin: aa112901/remusic

@Override
  public void onStart() {
    super.onStart();
//        animatorWeakReference = new  WeakReference<ObjectAnimator>(new ObjectAnimator());
//        animator = animatorWeakReference.get();
    animatorWeakReference = new WeakReference(ObjectAnimator.ofFloat(getView(), "rotation", new float[]{0.0F, 360.0F}));
    animator = animatorWeakReference.get();
    //animator = ObjectAnimator.ofFloat(getView(), "rotation", new float[]{0.0F, 360.0F});
    animator.setRepeatCount(Integer.MAX_VALUE);
    animator.setDuration(25000L);
    animator.setInterpolator(new LinearInterpolator());

    if (getView() != null)
      getView().setTag(R.id.tag_animator, this.animator);
  }

代码示例来源:origin: xfumihiro/ViewInspector

@SuppressWarnings("deprecation") public void closeToolbar() {
 closeMenu();
 ObjectAnimator animator =
   ObjectAnimator.ofFloat(mToolbar, "translationX", mToolbar.getTranslationX(), mToolbarWidth);
 animator.setInterpolator(new DecelerateInterpolator());
 animator.start();
 mToggleButton.setImageDrawable(
   getResources().getDrawable(R.drawable.ic_chevron_left_white_24dp));
}

代码示例来源:origin: frogermcs/InstaMaterial

public void startFromLocation(int[] tapLocationOnScreen) {
  changeState(STATE_FILL_STARTED);
  startLocationX = tapLocationOnScreen[0];
  startLocationY = tapLocationOnScreen[1];
  revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME);
  revealAnimator.setInterpolator(INTERPOLATOR);
  revealAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_FINISHED);
    }
  });
  revealAnimator.start();
}

代码示例来源:origin: qiujuer/Genius-Android

private ObjectAnimator getTitleAnimator() {
  if (mAnimator == null) {
    if (mCurTitleProperty == null)
      mCurTitleProperty = new TitleProperty();
    mAnimator = ObjectAnimator.ofObject(this, TITLE_PROPERTY, new TitleEvaluator(mCurTitleProperty), mCurTitleProperty);
    mAnimator.setDuration(ANIMATION_DURATION);
    mAnimator.setInterpolator(ANIMATION_INTERPOLATOR);
  } else {
    mAnimator.cancel();
  }
  return mAnimator;
}

相关文章