I have a ViewFlipper which runs a view animation when showPrevious is called. The animation works out fine. But the problem is it starts with a delay of over 1 seconds. Now this doesn't seem like much but it seriously delays usage of the app.
My animations look like this;
Animation inFromLeft = 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);
inFromLeft.setDuration(350);
inFromLeft.setInterpolator(new LinearInterpolator());
Animation outtoRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoRight.setDuration(350);
outtoRight.setInterpolator(new LinearInterpolator());
I set the animations using setInAnimation
and setOutAnimation
;
setInAnimation(inFromLeft);
setOutAnimation(outtoRight);
And then I just launch the animation using showPrevious
Is there any reason why the animations starts with a delay of over 1 seconds, the startTime for the animations is -1 and the startOffset is 0.
android.widget.ViewFlipper. Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.
Two suggestions. First, if possible, change over to using ViewPager. Second, if the first is not possible, then use XML-based animations. Pushing stuff out of code and into resources is usually a win.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With