【问题标题】:passing null to setInterpolator crashes将 null 传递给 setInterpolator 崩溃
【发布时间】:2014-05-19 20:17:36
【问题描述】:

我正在使用 TranslateAnimation 对象为我的视图设置动画。但它具有默认的缓入和缓出效果。我不想要任何效果。将 null 传递给 setInterpolator() 方法会使我的应用程序崩溃。我应该传递什么作为论点以便没有影响?或者有什么其他的方法吗?

【问题讨论】:

    标签: android animation tween


    【解决方案1】:

    不要将null 传递给setInterPolator。默认('无影响')是LinearInterpolator,它具有恒定的变化率。

    Docs:

    public void setInterpolator (Interpolator i)

    设置此动画的加速曲线。
    默认为线性插值。

    【讨论】:

    • 谢谢!! setInterpolator(new LinearInterpolator()) 完成了这项工作!虽然它说它默认为线性插值,但不知何故它具有加速效果。无论如何..现在效果很好!
    • 很高兴听到!祝你好运。
    【解决方案2】:

    使用setInterpolator(LinearInterpolator)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 2010-11-21
      • 1970-01-01
      • 2019-03-20
      • 2020-02-02
      • 1970-01-01
      相关资源
      最近更新 更多