The property animation system provides a way for us to animate properties of any object, such as its position or opacity. It is also able to animate properties of custom types.
The ValueAnimator
type lets us animate values of some type for the duration of an animation by specifying set values to animate through. Let's take a look at the following steps:
We obtain a
ValueAnimator
type by calling one of its factory methods, such asOfInt
,OfFloat
, orOfObject
. The instance is then used to tween a value from one value to another:ValueAnimator animator = ValueAnimator.OfInt(1, 1000); animator.SetDuration(5000); animator.SetInterpolator(new BounceInterpolator()); animator.Start();
We can also use the
ObjectAnimator
property to tween a property value from one value to another, in this case theAlpha
property:ObjectAnimator animator = ObjectAnimator.OfFloat( myButton, "alpha", 1.0f, 0.0f, 1.0f); animator.SetDuration(5000); animator.SetInterpolator...