0

我正在创建一个动画,其中我有 3 个将在屏幕上显示动画的图像。当中间图像到达屏幕中间时,它会淡入。

一切都工作正常,除了只有当第一张图像打到中间时它会淡入,当第二张和第三张图像打到中间时它们不会淡入。

每个图像都有自己的视图。并且淡入方法在所有相同的视图上执行。

请看下面的代码。如果您需要更多信息,请告诉我。

这是模拟幻灯片在屏幕上移动的过程。moveThree 是动画中的淡入淡出。moveOne 和 moveTwo 是屏幕上图像的翻译。

 public static int secondProcess(AnimationListener activity, View apa1,View apa2, View apa3,int animationmove)
 {
     Log.d("2", "SECOND PROCESS");
     moveOne(activity, apa2);
     moveTwo(activity,apa1);
     animationmove = 3;
     return animationmove;

 }

 public static int thirdProcess(AnimationListener activity, View apa1,View apa2,View apa3, int animationmove)
 {
     Log.d("3", "THIRD PROCESS");
     moveThree(activity,apa1);
     animationmove = 4;
     return animationmove; 
 }

 public static int fourthProcess(AnimationListener activity, View apa1, View apa2,View apa3,int animationmove)
 {
     Log.d("4", "FOURTH PROCESS");
     moveOne(activity, apa3);
     moveTwo(activity, apa2);
     moveFour(activity,apa1);
     animationmove = 5;
     return animationmove;

 }


 public static int fifthProcess(AnimationListener activity, View apa1,View apa2,View apa3, int animationmove)
 {
     Log.d("5", "FIFTH PROCESS");
     moveThree(activity,apa2);//IN THE SECOND VIEW HERE THE IMAGE IS NOT FADING 
     animationmove = 6;
     return animationmove; 

 }

moveThree 方法:

private static void moveThree(AnimationListener activity, View apa)
{
    Log.v("MOVETHREE", "Started move3");
    AnimationSet picMov3 = new AnimationSet(true);
    picMov3.setAnimationListener(activity);
    AlphaAnimation fadein = new AlphaAnimation((float) 0.3, 1);
    fadein.setFillAfter(true);

    fadein.setDuration(duration);
    picMov3.addAnimation(fadein);
    TranslateAnimation trans1 = new TranslateAnimation(-500, -500, 0, 0);
    trans1.setDuration(duration);
    picMov3.setFillAfter(true);
    picMov3.setInterpolator(interpolator);
    picMov3.addAnimation(trans1);

    apa.startAnimation(picMov3);


}
4

1 回答 1

1

您只为第一个视图调用 moveThree。您还需要为其他视图调用 if:

moveThree(activity,apa1);
moveThree(activity,apa2);
moveThree(activity,apa3);
于 2012-04-09T13:30:43.997 回答