無視という表現が正しいかわからないけれども、何も起きなくなる。ただしAnimationListernerはAnimationEndを検知する。
どういう時に起きるのかというと
AnimationSet animationSet = new AnimationSet(true); RotateAnimation rotationAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); TranslateAnimation translateAnimation = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 500, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 500); animationSet.setDuration(250); animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setFillAfter(true); animationSet.addAnimation(rotationAnimation); // addAnimationを最初に呼ばない animationSet.addAnimation(translateAnimation); animationSet.setAnimationListener(new OnAnimationListerner(省略)); imageView.startAnimation(animationSet);
こんな順番で書くと、このアニメーションは実行されない。
AnimationSet animationSet = new AnimationSet(true); RotateAnimation rotationAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); TranslateAnimation translateAnimation = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 500, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 500); animationSet.addAnimation(rotationAnimation); // addAnimationをどのメソッドよりも先に呼ぶ animationSet.addAnimation(translateAnimation); animationSet.setDuration(250); animationSet.setInterpolator(new DecelerateInterpolator()); animationSet.setFillAfter(true); animationSet.setAnimationListener(new OnAnimationListerner(省略)); imageView.startAnimation(animationSet);
こうすると動く。ちなみに4.x系ではどちらでも期待通りの動きをする。
4.x系ではどうやら同じAnimationSetでも中身が違うようだ。
ソースはまだ見比べていないので、どう違うのか、なんで動かないのかは調べていない。
そのうち調べる(←調べない)