A
To instantiate a
Keyframe object consists of a time/value pair that
lets you define a specific state at a specific time of an animation.
Each keyframe can also have its own interpolator to control the behavior
of the animation in the interval between the previous keyframe's time
and the time of this keyframe.To instantiate a
Keyframe object, you must use one of the factory methods, ofInt(), ofFloat(), or ofObject() to obtain the appropriate type of Keyframe. You then call the ofKeyframe() factory method to obtain a PropertyValuesHolder object. Once you have the object, you can obtain an animator by passing in the PropertyValuesHolder object and the object to animate. The following code snippet demonstrates how to do this:Keyframe kf0 = Keyframe.ofFloat(0f, 0f); Keyframe kf1 = Keyframe.ofFloat(.5f, 360f); Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(target, pvhRotation) rotationAnim.setDuration(5000ms);For a more complete example on how to use keyframes, see the MultiPropertyAnimation sample in APIDemos.
No comments:
Post a Comment