sAr sAr - 1 year ago 166
Android Question

ObjectAnimator duration not respected

I'm trying to create an animation in order to scroll automatically in my scrollview.

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

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


My animation is working perfectly, I scroll from the top of my scrollview content to the bottom BUT I do it in 96 seconds, instead of the 154 seconds set in duration.

Does anyone know why ? I check developer settings of my phone, tried on two devices, still the same problem.

Answer Source

your target "scrollY" is probably wrong (the last param of ofInt), you need something like this:

height_of_content - height_of_container
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download