android - 有没有办法消除动画的插值?

标签 android animation interpolation viewflipper

我确定我遗漏了一些明显的东西,但我无法让我的 ViewFlipper 从一个布局平滑地动画到另一个布局。

我的愿望是让动画以恒定速度移动。不加速或减速。总体期望的效果是让鳍状肢永久动画,没有明显的卡顿或打嗝,这样两个(或更多)布局就可以继续移动,就像在环形卷轴上一样。

但是,当我不设置插值时,它默认为*一些默认的内置插值,在最后减慢到 0。

当我*设置插值时,似乎没有数字可以传递给我平滑的动画结果。 0 完全停止动画,1 执行(看似)默认值的操作。

我忽略了什么?

这是我传递的动画方法(作为我自定义 Animation 的一部分到 ViewFlipper:

public Animation inFromRightAnimation(int duration) {
    Animation inFromRight = new TranslateAnimation(
    Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
    Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    );
    inFromRight.setDuration(duration);
    AccelerateInterpolator ai = new AccelerateInterpolator();//tried 0 and 1.0f as params without success

    inFromRight.setInterpolator(ai); //
    return inFromRight;
}

最佳答案

尝试使用 LinearInterpolator 而不是 AccelerateInterpolatorLinearInterpolator 确保您的 View 将以恒定速度移动,没有任何加速或减速。

关于android - 有没有办法消除动画的插值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22260506/

相关文章:

iphone - 建立一个漂亮的进度条

javascript - 将文本放在 jquery 动画的一侧

c++ - 角度的 Slerp 插值结果为 -nan(ind)

angularjs - 用于动态电子邮件的 Angular $compile 模板

android - 根据第一个 Activity 更改第二个 Activity 的标题

Android软键盘问题

Android 主屏幕小部件动画

python - 插值到特定时间

java - 如何在phonegap中拼接照片和音频文件

android - 检查Android互联网连接的完美功能,包括蓝牙锅