java 适用于Android动画的更具配置性的反弹内插器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 适用于Android动画的更具配置性的反弹内插器相关的知识,希望对你有一定的参考价值。

import android.view.animation.Interpolator;

import static java.lang.Math.*;

public class BetterBounceInterpolator implements Interpolator {
  private int mBounces;
  private double mEnergy;

  /** Have more control over how to bounce your values.
   *
   */
  public BetterBounceInterpolator(){
    this(3);
  }

  /** Have more control over how to bounce your values.
   *
   * @param bounces number of times to bounce before coming to a rest
   */
  public BetterBounceInterpolator(int bounces){
    this(bounces, 0.3f);
  }

  /** Have more control over how to bounce your values.
   *
   * @param bounces number of times to bounce before coming to a rest
   * @param energyFactor control how the bounce loses momentum. 0 is lose energy linearly. 1 energy loss slows down over time, -1 energy loss speeds up over time. Values greater than 1 and less than -1 cause over/under bounce
   */
  public BetterBounceInterpolator(int bounces, double energyFactor){
    mBounces = bounces;
    mEnergy = energyFactor + 0.5;
  }

  @Override public float getInterpolation(float x) {
    return (float) (1d + (-abs(cos(x * 10 * mBounces/PI)) * getCurveAdjustment(x)));
  }

  private double getCurveAdjustment(double  x){
    return -(2 * (1 - x) * x * mEnergy + x * x) + 1;
  }
}

以上是关于java 适用于Android动画的更具配置性的反弹内插器的主要内容,如果未能解决你的问题,请参考以下文章

Android 动画之Gif动画的用法(适用于Android9.0以上和以下)

适用于 Android 和 IOS 的 HighChart 库 [关闭]

我想在setVisibility上制作动画视图,但它仅适用于第一次

java 适用于Android的领域数据库

java 适用于Android的简单LocalBinder演示

ActionScript 3 适用于Android的Adobe Air文件配置