不遵守 ObjectAnimator 持续时间

ObjectAnimator duration not respected

我正在尝试创建一个动画以便在我的滚动视图中自动滚动。

LinearLayout linearLayout = (LinearLayout) scrollView.getChildAt(0);
// linearLayout.getHeight() == 540
animScroll = ObjectAnimator.ofInt(scrollView, "scrollY", linearLayout.getHeight());

// animationDurationLong == 154000
animScroll.setDuration(animationDurationLong);
animScroll.setInterpolator(new LinearInterpolator());

animScroll.start();

我的动画运行完美,我从滚动视图内容的顶部滚动到底部但我在 96 秒内完成,而不是持续时间中设置的 154 秒。

有谁知道为什么?我检查了我 phone 的开发者设置,在两台设备上都试过了,仍然是同样的问题。

你的目标"scrollY"可能是错误的(ofInt的最后一个参数),你需要这样的东西:

height_of_content - height_of_container