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?
The animations are basically of three types as follows: Property Animation. View Animation. Drawable Animation.
On Android 4.4 (API level 19) and higher, you can use the transition framework to create animations when you swap the layout within the current activity or fragment. All you need to do is specify the starting and ending layout, and what type of animation you want to use.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With