淡入只发生在第一个动画android

时间:2012-04-09 13:24:27

标签: android android-animation android-imageview android-image

我正在创建一个动画,其中有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);


}

1 个答案:

答案 0 :(得分:1)

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

moveThree(activity,apa1);
moveThree(activity,apa2);
moveThree(activity,apa3);