objectanimator只工作到卷轴的中间,而不是底部

t1rydlwq  于 2021-07-04  发布在  Java
关注(0)|答案(1)|浏览(279)

动画启动,但只会持续到卷轴中间的某个特定位置。是什么导致了这种奇怪的行为?请帮我提些建议!

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();
        }
    });
}
9cbw7uwe

9cbw7uwe1#

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();

相关问题