I'm sure I'm missing something obvious but I'm unable to get my ViewFlipper to animate smoothly from one layout to the next.

My desire is to have the animation move at a constant speed. Not to accel or decel. The overall desired effect is to have the flipper animate in perpetuity with no visible stutter or hiccup, so that the two (or more) layouts just keep moving along, as though on a looped reel.

However, when I don't set an Interpolation it defaults to *some default built-in interpolation that slows down to 0 towards the end.

And when I *do set the Interpolation there's no number I seem to be able to pass in to give me the smooth animation result. 0 stops the animation outright and 1 does (seemingly) what the default does.

What am I overlooking?

here's my animation method that I am passing (as part of my custom Animation to the ViewFlipper:

public Animation inFromRightAnimation(int duration) {
    Animation inFromRight = 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
    );
    inFromRight.setDuration(duration);
    AccelerateInterpolator ai = new AccelerateInterpolator();//tried 0 and 1.0f as params without success

    inFromRight.setInterpolator(ai); //
    return inFromRight;
}
有帮助吗?

解决方案

Try using LinearInterpolator instead of AccelerateInterpolator. LinearInterpolator ensures that your views will move with a constant velocity without any acceleration or deceleration.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top