androidanimationviewchainingchained

How to chain animation in android to the same view?


I got some text views and I want to make the buzz effect of MSN.

My plan is:

My point is, I have some sequence of movements that I want to set to one view and that needs to execute one after another.

How can I do that?


Solution

  • Use an AnimationSet:

    AnimationSet set = new AnimationSet(true);
    
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(100);
    set.addAnimation(animation);
    
    animation = new TranslateAnimation(
        Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
        Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
    );
    animation.setDuration(500);
    set.addAnimation(animation);
    
    view.startAnimation( set );