如何同时为多个按钮设置动画?

时间:2013-01-19 15:07:46

标签: java android translate-animation

我正在尝试同时在多个ImageViews(按钮)上进行翻译动画。但是,TranslateAnimations因每个ImageView而异,所以我将它们放在AnimationSet中。问题是,某种程度上动画永远不会运行......我不知道为什么。这是我的代码:

ArrayList<TranslateAnimation> animlist = new ArrayList<TranslateAnimation>();
AnimationSet set = new AnimationSet(true);

//The following for-loop is actually running inside two other for loops... I'm        skimming it down a little for you guys
for(int i = ROWS-1; i > row;i--){
    if(!usedFields[column][i]){
        ImageView iv = (ImageView)GameLayout.findViewWithTag(""+row+","+column);
        TranslateAnimation transanim = new TranslateAnimation(0,0,-(i-row)*letterHeight,0);
        transanim.setDuration(1000);
        iv.setAnimation(transanim);
        animlist.add(transanim);
        break;
    }
}

for (TranslateAnimation anim : animlist){
    set.addAnimation(anim);         
}

set.startNow();

谢谢,我很感激!

0 个答案:

没有答案