Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1
State list animators

State list animators


Material applications are often designed with many animated user interactions. Press a button on a
device running Lollipop or later to see one example: The button will animate up on the z-axis to meet
your finger. When you release your finger, it will animate back down.


To make implementing these animations easier, Lollipop introduced state list animators. State list
animators are the animation counterpart to the state list drawable: Instead of switching out one
drawable for another, they animate the view into a particular state. To implement an animation that
raises the button up when you press it, you can define a state list animator that looks like this in res/
animator:


Listing 35.2  An example state list animator




android:duration="100"
android:valueTo="6dp"
android:valueType="floatType"
/>


android:duration="100"
android:valueTo="0dp"
android:valueType="floatType"
/>

Free download pdf