AnimationSet plays in reverse order

I use AnimationSet to do a lot of translation translations. In this example, I want to move the ImageView from 0 to 700 (off screen) and -700 to 0 (the view is moved to the far right and re-entered from the far left). I am using this code:

    AnimationSet set = new AnimationSet(true);
    set.setInterpolator(new AccelerateDecelerateInterpolator());
    set.setFillEnabled(true);
    if(traject!=null){
        TranslateAnimation tmpAnim = null;
        set.setDuration(duration);
        int d = traject.size()!=0 ? duration/traject.size() : duration;

        for(int i =0; i<traject.size();i++){
            tmpAnim = new TranslateAnimation( traject.get(i).getStartX(),
                                            traject.get(i).getEndX(),
                                            traject.get(i).getStartY(),
                                            traject.get(i).getEndY() );
            tmpAnim.setDuration(d);
            tmpAnim.setFillAfter(true);
            tmpAnim.setStartOffset(d*i);
            set.addAnimation(tmpAnim);
        }
    }

      

  • traject is an arraylist holding each of the start and end points of the TranslateAnimation.

But in my test case the animation goes from -700 to 700. I tried to switch the order of TranslateAnimations using setStartTime () instead of setStartOffset (), skipping the call to setStartOffset (), the result is the same. Do you have an idea what I'm missing?

+3


source to share





All Articles