Android properties that can be animated with ObjectAnimator

The Docs imply that any value can be used with ObjectAnimator as long as you follow a naming convention:

  1. The object property that you are animating must have a setter function (in camel case) in the form of set<propertyName>(). Because the ObjectAnimator automatically updates the property during animation, it must be able to access the property with this setter method. For example, if the property name is foo, you need to have a setFoo() method. If this setter method does not exist, you have three options:
    • Add the setter method to the class if you have the rights to do so.
    • Use a wrapper class that you have rights to change and have that wrapper receive the value with a valid setter method and forward it to the original object.
    • Use ValueAnimator instead.
  2. [...]

With respect to your question, View has the method setRotation(float) -- that gives you a hint it can be used. In particular here's how you would do it with a particular TimeInterpolator:

ObjectAnimator anim = ObjectAnimator.ofFloat(myView, "rotation", 0f, 90f);
anim.setDuration(2000);                  // Duration in milliseconds
anim.setInterpolator(timeInterpolator);  // E.g. Linear, Accelerate, Decelerate
anim.start()                             // Begin the animation

You can read the docs for more details on the expectations of ObjectAnimator.


Better late than never, so here is the comprehensive list of the properties that can be animated with ObjectAnimator.

http://developer.android.com/guide/topics/graphics/prop-animation.html#views


Here is the comprehensive list of property names that you are looking for:

  • rotation
  • rotationX
  • rotationY
  • translationX
  • translationY
  • scaleX
  • scaleY
  • pivotX
  • pivotY
  • alpha
  • x
  • y

Source: Docs