如何添加动画之间的延迟 [英] How to add delay between animations

查看:282
本文介绍了如何添加动画之间的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Android中的动画麻烦。我有我的animation_char.xml:

 <设置的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
<阿尔法
    机器人:时间=300
    机器人:fromAlpha =0.0
    机器人:插值=@机器人:动画/ accelerate_interpolator
    机器人:toAlpha =1.0/>
< /集>

这是好的,但在我的MainActivity我要开始一个接一个的动画之一。因此,我创建,使其更容易,只是改变ImageView的方法

 公共无效动画(ImageView的ImageView的){
    动画= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animation_char);
    imageView.startAnimation(动画);
}

和make的consecutives动画,我试图用AnimatorSet。但是,当我读AnimatorSet适用于动画,而不是与动画。所以我的问题是:
有没有办法来加载一个动画的动画?或者我应该用另一种方式,以达到我想要做什么?在此先感谢!

修改
我改变了我的方法,现在林这个尝试,但问题是,所有的图像显示在同一时间,我怎么可以添加动画之间有一些延迟?

 公共无效动画(){
    动画= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animation_char);            w.startAnimation(动画);
            a.startAnimation(动画);
            r.startAnimation(动画);
}


解决方案

其实我已经回答了这个问题,<一个href=\"http://stackoverflow.com/questions/34024128/how-to-start-a-function-when-animation-has-ended/34024276#34024276\">here.你应该在 onAnimationEnd 开始你的第二个动画第一动画AnimationListener的。同为第二个。

I'm having a trouble with animations in android. I have my animation_char.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
    android:duration="300"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toAlpha="1.0"/>
</set>

That is ok, but in my MainActivity I want to start an animation one after one. So I created a method to make it more easy and just change the ImageView

public void animation(ImageView imageView){
    animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animation_char);
    imageView.startAnimation(animation);
}

And for make consecutives animations, I'm trying to use AnimatorSet. But as I read AnimatorSet works with Animator, not with Animation. So my question is: is there a way to load an animation in a animator?? Or should I use another way in order to achieve what I want to do? Thanks in advance!

EDIT I changed my method and now Im trying with this but the problem is that all the images appear at the same time, how can I add some delay between animations?

public void animation() {
    animation= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animation_char);

            w.startAnimation(animation);
            a.startAnimation(animation);
            r.startAnimation(animation);     
}

解决方案

Actually I've answered on this question here. You should start your second animation in onAnimationEnd of AnimationListener of first animations. The same for second one.

这篇关于如何添加动画之间的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆