如何在Android中创建动态启动画面?

4
我看到一个由设计师为移动应用程序设计的链接。我想要实现这种效果或动画,但我不知道该如何描述。
请指导我如何在Android应用程序启动屏幕中实现完全相同的效果。
我需要那个GIF图像并在WebView中显示吗?
还是需要任何类型的Drawable-Animation?
任何建议和帮助将不胜感激。
提前致谢。
2个回答

3
你可以使用AnimatorSet

这个类按指定顺序播放一组动画对象。动画可以同时播放、依次播放或者在指定延迟后播放。

向AnimatorSet添加动画有两种不同的方法:playTogether()或playSequentially()方法可用于一次性添加一组动画,而play(Animator)可与Builder类中的方法一起使用,逐个添加动画。

可以设置具有循环依赖关系的AnimatorSet。例如,可以设置一个动画a1在动画a2之前开始,a2在a3之前开始,a3在a1之前开始。这种配置的结果是未定义的,但通常会导致受影响的动画都没有播放。因此(而且循环依赖关系也没有逻辑意义),应避免循环依赖关系,并且动画的依赖流应该只朝一个方向。

您可以查看以下链接以获取演示案例

  1. Android消化屏幕

0
要做的是,在您提供的图像上,所有这些都只是单个图像,在一定的超时时间后从一个图像过渡到另一个图像。
您需要为每个过渡帧加载大量图像,然后相应地移动它们。
这有点像在Android上创建启动动画。每个图像将代表总动画的一个单独帧。
要对图像进行动画处理,请尝试以下方法(基本上使用alpha进行过渡)。
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://dev59.com/6V0Z5IYBdhLWcg3w4jhy#32199671


2
链接永远不是一个好答案。请解释为什么您认为这可以帮助解决所述的问题。如果您不确定,那么这可能不应该是一个答案,而应该是一个评论。 - MH.
好的,没问题,我会在今晚完成,因为我现在有点忙。@MH。 - sayan
@MH。现在看看...也许去掉这个downer? - sayan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接