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?
You probably mean AnimatorSet (not AnimationSet). As written in documentation:
This class plays a set of
Animator
objects in the specified order. Animations can be set up to play together, in sequence, or after a specified delay.There are two different approaches to adding animations to a AnimatorSet: either the
playTogether()
orplaySequentially()
methods can be called to add a set of animations all at once, or theplay(Animator)
can be used in conjunction with methods in theBuilder
class to add animations one by one.
Animation which moves view
by -100px
for 700ms
and then disappears during 300ms
:
final View view = findViewById(R.id.my_view);
final Animator translationAnimator = ObjectAnimator
.ofFloat(view, View.TRANSLATION_Y, 0f, -100f)
.setDuration(700);
final Animator alphaAnimator = ObjectAnimator
.ofFloat(view, View.ALPHA, 1f, 0f)
.setDuration(300);
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(
translationAnimator,
alphaAnimator
);
animatorSet.start()