Chain animatorSet android animation

狂风中的少年 提交于 2019-12-24 07:05:37

问题


New to android i would like to make some smooth animation.

I have a file on device that contains effects and each effect is an animation. The file tells me when an effect will be played and the effect duration.

The problem is i cannot chain animatorSet dynmacily :

AnimatorSet mainAnimatorSet(); 
_listAllAnimator // Will contain every AnimatorSet(); 
for (int i = 0; i < listEffects; i++)
{
// Build animatorSet 
   ObjectAnimaTor1... 
   ObjectAnimaTor2... 
   AnimatorSet animatorSet = new AnimatorSet(); 
   animatorSet.play(ObjectAnimaTor1).with(ObjectAnimaTor2); 
   _listAllAnimator.add(animatorSet);

}

Now how can i want mainAnimatorSet() from my list of AnimatorSet(); each animations start at the end of the last one.

for (int i = 0; i < _listAllAnimator.size(); i++)
{
if (i==0) {
  mainAnimatorSet.play(animSet.get(i));
}
else {
    mainAnimatorSet.play(animSet.get(i)).after(animSet.get(i-1)); 
}
}
mainAnimatorSet.start(); 

This does not work. Thanks


回答1:


i dont really get you but i am posting an answer anyway..

1 supposing you you have animations in an arraylist or list and you want to play those animations in order of start-after-previous-end

AnimatorSet s = new AnimatorSet();
s.playSequentially(List<Animator> items); // items is your arraylist of animations

2 supposing you you have animations in an arraylist or list and you want to play those animations at the same time

AnimatorSet s = new AnimatorSet();
s.playTogether(List<Animator> items); // items is your arraylist of animations


来源:https://stackoverflow.com/questions/27576217/chain-animatorset-android-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!