我确定我遗漏了一些明显的东西,但我无法让我的 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
而不是 AccelerateInterpolator
。 LinearInterpolator
确保您的 View 将以恒定速度移动,没有任何加速或减速。
关于android - 有没有办法消除动画的插值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22260506/