Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android动画转向_Android_Rotateanimation - Fatal编程技术网

Android动画转向

Android动画转向,android,rotateanimation,Android,Rotateanimation,我使用下面的代码在一系列中转弯(向左或向右)。所以如果我一个接一个地叫它,即:turn(90);转(90);转弯(-90)它显示的是最后一个。我想展示给大家看,等到第一个完成后再继续下一个。有什么想法吗 public void turn(int i) { RotateAnimation anim = new RotateAnimation( currentRotation, currentRotation + i,

我使用下面的代码在一系列中转弯(向左或向右)。所以如果我一个接一个地叫它,即:
turn(90);转(90);转弯(-90)它显示的是最后一个。我想展示给大家看,等到第一个完成后再继续下一个。有什么想法吗

public void turn(int i)
{

    RotateAnimation anim = new RotateAnimation( currentRotation, currentRotation + i,
                                                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
                                                currentRotation = (currentRotation + i) % 360;

    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(1000);
    anim.setFillEnabled(true);

    anim.setFillAfter(true);
    token.startAnimation(anim);
}

所以我所做的就是创建一个动画和一个迭代器来运行它。。。在我定义了所有需要完成的动画并将它们添加到que之后,我运行了第一个动画,然后在AnimationListener中处理其余的动画

Queue<RotateAnimation> que = new LinkedList<RotateAnimation>();
Iterator<RotateAnimation> queIt;


public void turnToken(int i){

    RotateAnimation anim = new RotateAnimation( currentRotation, currentRotation + i,
                                                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
                                                currentRotation = (currentRotation + i) % 360;

    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(1000);
    anim.setFillEnabled(true);
    anim.setAnimationListener(this);
    anim.setFillAfter(true);

    que.add(anim);
}
@Override
public void onAnimationEnd(Animation arg0) {
    // TODO Auto-generated method stub

    if(queIt.hasNext()){
        token.startAnimation((Animation) queIt.next());
        }
}

@Override
public void onAnimationRepeat(Animation arg0) {
    // TODO Auto-generated method stub
}

@Override
public void onAnimationStart(Animation arg0) {
    // TODO Auto-generated method stub

}