O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating view and object properties

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.

How to do it...

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:

  1. We obtain a ValueAnimator type by calling one of its factory methods, such as OfInt, OfFloat, or OfObject. 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();
  2. We can also use the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required