Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewFlipper having 'huge' delay

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.

like image 226
Thizzer Avatar asked Aug 14 '12 13:08

Thizzer


People also ask

What is ViewFlipper in android?

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.


1 Answers

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.

like image 82
Sparky Avatar answered Sep 28 '22 03:09

Sparky