2015-11-24 154 views

回答

3

您可以使用AnimatorSet

该类扮演了一组指定的顺序动画的对象。 动画可以设置为一起播放,按顺序播放或在指定延迟后播放。

有两种不同的方法来添加动画到 AnimatorSet:要么playTogether()或playSequentially()方法 可以被称为一次全部添加一组动画,或 播放(动画)可与Builder 类中的方法一起使用以逐个添加动画。

可以在它的动画之间设置一个循环依赖关系为 的AnimatorSet。例如,可以将动画a1设置为 以在动画a2之前开始,在a3之前开始a2,在a1之前以a3开始。该配置的 结果未定义,但通常会导致 不受任何正在播放的受影响的动画的影响。由于这个原因(因为循环依赖关系无论如何都没有逻辑意义),所以应该避免循环依赖关系,并且动画的依赖关系流应该只在一个方向上。

您可以查看以下链接DEMP情况

  1. Digest Splash for Android
0

什么是必须要做的是,在图像上您所提供的所有这些都只是单一的图像在一定的超时时间之后,它们将从一个转换到另一个。

您需要为每个过渡帧添加大量图像,然后相应地移动它们。

它有点像在Android上创建启动动画。 每幅图像将代表整个动画的单个帧。

对于动画图像,试试这个(基本上是用来过渡的α)

ImageView demoImage = (ImageView) findViewById(R.id.DemoImage); 
int imagesToShow[] = { R.drawable.image1, R.drawable.image2,R.drawable.image3 }; 
animate(demoImage, imagesToShow, 0,false); 



private void animate(final ImageView imageView, final int images[], final int imageIndex, final boolean forever) { 

//imageView <-- The View which displays the images 
//images[] <-- Holds R references to the images to display 
//imageIndex <-- index of the first image to show in images[] 
//forever <-- If equals true then after the last image it starts all over again with the first image resulting in an infinite loop. You have been warned. 

int fadeInDuration = 500; // Configure time values here 
int timeBetween = 3000; 
int fadeOutDuration = 1000; 

imageView.setVisibility(View.INVISIBLE); //Visible or invisible by default - this will apply when the animation ends 
imageView.setImageResource(images[imageIndex]); 

Animation fadeIn = new AlphaAnimation(0, 1); 
fadeIn.setInterpolator(new DecelerateInterpolator()); // add this 
fadeIn.setDuration(fadeInDuration); 

Animation fadeOut = new AlphaAnimation(1, 0); 
fadeOut.setInterpolator(new AccelerateInterpolator()); // and this 
fadeOut.setStartOffset(fadeInDuration + timeBetween); 
fadeOut.setDuration(fadeOutDuration); 

AnimationSet animation = new AnimationSet(false); // change to false 
animation.addAnimation(fadeIn); 
animation.addAnimation(fadeOut); 
animation.setRepeatCount(1); 
imageView.setAnimation(animation); 

animation.setAnimationListener(new AnimationListener() { 
    public void onAnimationEnd(Animation animation) { 
     if (images.length - 1 > imageIndex) { 
      animate(imageView, images, imageIndex + 1,forever); //Calls itself until it gets to the end of the array 
     } 
     else { 
      if (forever == true){ 
      animate(imageView, images, 0,forever); //Calls itself to start the animation all over again in a loop if forever = true 
      } 
     } 
    } 
    public void onAnimationRepeat(Animation animation) { 
     // TODO Auto-generated method stub 
    } 
    public void onAnimationStart(Animation animation) { 
     // TODO Auto-generated method stub 
    } 
}); 

}

对于揭示活性动画的最后部分,请参阅本SO回答https://stackoverflow.com/a/32199671/4626943

+2

链接是*从来没有[一个好答案](http://stackoverflow.com/help/how-to-answer)。请解释*为什么*您认为这可能有助于解决所述问题。如果你不确定,那么这可能不应该是一个答案,而是一个评论。 –

+0

好的,今晚我会做,因为我目前有点忙。 @MH。 – sayan

+0

@MH。现在看..也许删除downer? – sayan

相关问题