Alex Rivera | Logout

ViewFlipper having 'huge' delay

Asked 2012-08-14T13:39:15.553
8

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.

Edit
Report

1 Answer

1

Are you sure the delay is happening in the animation? Have you tried adding some logging including the startAnimation method of an AnimationListener?

If you're sure the delay is coming after you start the animation, you might try using traceview between before you start the animation and after it's done (using an AnimationListener again). This will tell you what Android's doing in the meantime.

answered 2012-08-26T17:18:13.213

Your Answer