I'm trying to find a list of the properties that the ObjectAnimator can animate and how it animates them.
For instance I'd like to know how the translationY property is animated. Is the value the to coordinate or is it the distance?
ObjectAnimators
will actually animate anything with "set" in front of the name. So in the case of View there's setX(float)
, setY(float)
, setZ(float)
, setTranslationX(float)
, and so on.
Likewise, if you create a custom View that has their own properties, then just use set____(type)
syntax to use an ObjectAnimator
on it with no additional work.
Basically what they do is just call these methods at repeating intervals with values determined by the TimeInterpolator
that is set to the Animator
.
EDIT:
There's a lot of properties that can animate on a View, but here are a description of the more common ones.
setX/Y(float)
- This will animate the View to the exact X or Y coordinates of the parent View
that it is contained in. The pixel coordinates start at (0,0)
at the top-left corner and (getWidth(), height())
at the bottom-right. setY(float)
will adjust the getTop()
of the View and setX(float)
will adjust the getLeft()
of the view.
setTranslationX/Y(float)
- This will animate the View to the relative position of the View
to where the starting point is. So for example, if the View's getLeft()
returns 50, then when you call setTranslationX(25)
will move the View to the right 25 pixels to pixel 75. Likewise, setTranslationY(25)
will move the view down 25 pixels. Negative values will move it left and up respectively.
setRotation(float)
- This will rotate the View
around the given pivot point as defined by setPivotX(float)
and setPivotY(float)
. By default, the pivot point is at coordinates (0,0). You can set it to the center by doing something like this:
View viewToAnimate = getViewToAnimate();
float width = viewToAnimate.getWidth();
float height = viewToAnimate.getHeight();
viewToAnimate.setPivotX(width/2);
viewToAnimate.setPivotY(height/2);
setScaleX/Y(float)
- This will shrink or grow a View based on the Pivot point as described above. A value of "1.0f" will make it normal size. Anything less than "1" will shrink it and anything more than "1" will make it grow.