As with other types of animations, you can listen for property animation events. You do this by adding an implementation of the AnimatorListener interface before starting the animation. You can listen for a variety of events, including the start and end of an animation, and cancellations and repeats.
- [Voiceover] As with other types of animations,…you can listen for property animation…events by adding listener objects.…You do this with implementations of…interfaces before you start the animation.…First, in this application, animation events,…I'm going to add a string constant at the…top of my activity class.…I'll add private, static, final,…then the data type String, and I'll name it…TAG, uppercase, and I'll give it a value of AnimationEvents.…
Now, I'll go down to my on button click method,…and I'll add some code here before I call…the animator's start method.…There are two different kinds of listeners…I'm going to demonstrate.…The first is called the animator listener.…I'll call animator.addListener, and then I'll…pass in a new instance of the animator listener interface.…Android Studio expands that to include…the stubs for the four required methods for the four events:…start, end, cancel, and repeat.…
I'll add logging for the first event.…I'll type in logi in the onAnimationStart method,…and when I press enter or return,…
Released
6/3/2016- Choosing an animation technique
- Defining and running view animations
- Animating with frames
- Animating object properties
- Animating transitions between activities and slides
- Using the transitions framework
Share this video
Embed this video
Video: Listen for animation events