我正在尝试多次实现包含多个动画(平移、旋转和 Alpha)的 AnimationSet。意思是在动画完成并到达某个点后,它将使用不同的动画参数再次运行。我通过使用参数来完成此操作setStartOffset;
以便在动画中计时。但是,我遇到了问题动画不是从其原始位置(r1、alpha1 和 trans1)开始,而是从不同的位置开始。有什么方法可以说明哪个动画将开始?
////////////////////////////111111//////////////////////
RotateAnimation r1 = new RotateAnimation(0,7,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
r1.setDuration(mAnimationDuration);
r1.setFillAfter(true);
r1.setInterpolator(interpolator);
AlphaAnimation alpha1 = new AlphaAnimation((float) 0.7, (float) 0.7);
alpha1.setDuration(mAnimationDuration);
alpha1.setFillAfter(true);
alpha1.setInterpolator(interpolator);
TranslateAnimation trans1 = new TranslateAnimation(0, -290, 0, 0);
trans1.setDuration(mAnimationDuration);
trans1.setFillAfter(true);
trans1.setInterpolator(interpolator);
/////////////////////222222222222/////////////////////////
RotateAnimation r2 = new RotateAnimation(7, -7,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
r2.setDuration(mAnimationDuration);
r2.setFillAfter(true);
r2.setInterpolator(interpolator);
r2.setStartOffset(mAnimationDuration);
AlphaAnimation alpha2 = new AlphaAnimation((float) 0.7, 1);
alpha2.setDuration(mAnimationDuration);
alpha2.setFillAfter(true);
alpha2.setInterpolator(interpolator);
alpha2.setStartOffset(mAnimationDuration);
TranslateAnimation trans2 = new TranslateAnimation(-290, -580, 0, 0);
trans2.setDuration(mAnimationDuration);
trans2.setFillAfter(true);
trans2.setInterpolator(interpolator);
trans2.setStartOffset(mAnimationDuration);
//////////////3333333///////////////////////////////
RotateAnimation r3 = new RotateAnimation(-7, -7,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
r3.setDuration(mAnimationDuration);
r3.setFillAfter(true);
r3.setInterpolator(interpolator);
r3.setStartOffset(mAnimationDuration*2);
AlphaAnimation alpha3 = new AlphaAnimation((float) 0.7, 1);
alpha3.setDuration(mAnimationDuration);
alpha3.setFillAfter(true);
alpha3.setInterpolator(interpolator);
alpha3.setStartOffset(mAnimationDuration*2);
TranslateAnimation trans3 = new TranslateAnimation(-580, -580, 0, 0);
trans3.setDuration(mAnimationDuration);
trans3.setFillAfter(true);
trans3.setInterpolator(interpolator);
trans3.setStartOffset(mAnimationDuration*2);
/////////////4/44444//////////////////////
RotateAnimation r4 = new RotateAnimation(-7, 7,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
r4.setDuration(mAnimationDuration);
r4.setFillAfter(true);
r4.setInterpolator(interpolator);
r4.setStartOffset(mAnimationDuration*3);
AlphaAnimation alpha4 = new AlphaAnimation(1, 1);
alpha4.setDuration(mAnimationDuration);
alpha4.setFillAfter(true);
alpha4.setInterpolator(interpolator);
alpha4.setStartOffset(mAnimationDuration*3);
TranslateAnimation trans4 = new TranslateAnimation(-580, -870, 0, 0);
trans4.setDuration(mAnimationDuration);
trans4.setFillAfter(true);
trans4.setInterpolator(interpolator);
trans4.setStartOffset(mAnimationDuration*3);
//////////////555555555555////////////////////////////
RotateAnimation r5 = new RotateAnimation(7, -7,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
r5.setDuration(mAnimationDuration);
r5.setFillAfter(true);
r5.setInterpolator(interpolator);
r5.setStartOffset(mAnimationDuration*4);
AlphaAnimation alpha5 = new AlphaAnimation(1, 1);
alpha5.setDuration(mAnimationDuration);
alpha5.setFillAfter(true);
alpha5.setInterpolator(interpolator);
alpha5.setStartOffset(mAnimationDuration*4);
TranslateAnimation trans5 = new TranslateAnimation(-870, -1160, 0, 0);
trans5.setDuration(mAnimationDuration);
trans5.setFillAfter(true);
trans5.setInterpolator(interpolator);
trans5.setStartOffset(mAnimationDuration*4);
firstAnimationView1 = new AnimationSet(true);
firstAnimationView1.addAnimation(r1);
firstAnimationView1.addAnimation(r2);
firstAnimationView1.addAnimation(r3);
firstAnimationView1.addAnimation(alpha1);
firstAnimationView1.addAnimation(alpha2);
firstAnimationView1.addAnimation(alpha3);
firstAnimationView1.addAnimation(trans1);
firstAnimationView1.addAnimation(trans2);
firstAnimationView1.addAnimation(trans3);