【问题标题】:How to create a ScaleX ObjectAnimator with increasingly fast end?如何创建一个端越来越快的 ScaleX ObjectAnimator?
【发布时间】:2017-02-15 08:02:27
【问题描述】:

我正在开发一个动画,它必须显示一个视图以更快的速度逐渐增加其大小。我想达到和你看到汽车来时一样的效果。远的时候,来的动作慢,但车辆越近,车子的速度越快。

当使用 ScaleX 和 ObjectAnimator 时,你有一些插值的可能性:

AccelerateDeccelerateInterpolator (default) -> very slow when the animation is close to finish...
AccelerateInterpolator -> Also slowing when the ScaleX is too much huge.
LinearInterpolator -> Even more slower when the ScaleX is too much huge.
FastOutSlowInInterpolator -> Still slow at the end.

ScaleX动画如何获得随时间增加比例尺速度的效果?

我的示例代码:

scaleX =  ObjectAnimator.ofFloat(view, "scaleX", 0.1f, 20f);        
scaleX.setDuration(10000);
scaleX.setInterpolator(new AccelerateInterpolator());
scaleX.start();

谢谢

【问题讨论】:

    标签: android android-animation scale interpolation objectanimator


    【解决方案1】:

    解决了使用此网络创建自定义三次贝塞尔曲线的问题:https://matthewlein.com/ceaser/

    Interpolator customInterpolator = PathInterpolatorCompat.create(cpX1,cpX2,cpY1,cpY2)
    

    生成的曲线与此类似:

         |
         |
    _____/
    

    【讨论】:

      猜你喜欢
      • 2018-02-05
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-18
      相关资源
      最近更新 更多