对象动画师只工作到中间,而不是滚动的底部

Object animator works only till the middle, not the bottom of scroll

动画开始播放,但只播放到卷轴中间某处的特定位置。什么会导致这种奇怪的行为?请大家帮忙出出主意!

public void scrollAnimation() {
    // Scroll activity!
    final ScrollView mScrollView = (ScrollView) findViewById(R.id.myScrollViewID);
    mScrollView.post(new Runnable() {
        public void run()
        {
            ObjectAnimator anim = ObjectAnimator.ofInt(mScrollView, "scrollY", mScrollView.getBottom());
            anim.setDuration(3000);
            anim.start();
        }
    });
}
AnimatorSet animators = new AnimatorSet();
 int y = 8000; // pixels how far will go the scroll
final ScrollView mScrollView = (ScrollView) findViewById(R.id.myScrollViewID);
final ObjectAnimator yTranslate = ObjectAnimator.ofInt(mScrollView, "scrollY", y);
animators.setDuration(100000L); // speed of scroll (greater the value -- greater the speed)

animators.play(yTranslate);
animators.start();

我认为你需要 2 个值。像这样

ObjectAnimator.ofInt(v, "scrollY", 
v.getChildAt(0).getHeight()
- v.getHeight());