|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.nineoldandroids.animation.Animator
com.nineoldandroids.animation.ValueAnimator
com.nineoldandroids.animation.ObjectAnimator
public final class ObjectAnimator
This subclass of ValueAnimator provides support for animating properties on target objects.
The constructors of this class take parameters to define the target object that will be animated
as well as the name of the property that will be animated. Appropriate set/get functions
are then determined internally and the animation will call these functions as necessary to
animate the property.
setPropertyName(String)| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.nineoldandroids.animation.ValueAnimator |
|---|
ValueAnimator.AnimatorUpdateListener |
| Nested classes/interfaces inherited from class com.nineoldandroids.animation.Animator |
|---|
Animator.AnimatorListener |
| Field Summary |
|---|
| Fields inherited from class com.nineoldandroids.animation.ValueAnimator |
|---|
INFINITE, RESTART, REVERSE |
| Constructor Summary | |
|---|---|
ObjectAnimator()
Creates a new ObjectAnimator object. |
|
| Method Summary | ||
|---|---|---|
ObjectAnimator |
clone()
|
|
String |
getPropertyName()
Gets the name of the property that will be animated. |
|
Object |
getTarget()
The target object whose property will be animated by this animation |
|
static ObjectAnimator |
ofFloat(Object target,
String propertyName,
float... values)
Constructs and returns an ObjectAnimator that animates between float values. |
|
static
|
ofFloat(T target,
Property<T,Float> property,
float... values)
Constructs and returns an ObjectAnimator that animates between float values. |
|
static ObjectAnimator |
ofInt(Object target,
String propertyName,
int... values)
Constructs and returns an ObjectAnimator that animates between int values. |
|
static
|
ofInt(T target,
Property<T,Integer> property,
int... values)
Constructs and returns an ObjectAnimator that animates between int values. |
|
static ObjectAnimator |
ofObject(Object target,
String propertyName,
TypeEvaluator evaluator,
Object... values)
Constructs and returns an ObjectAnimator that animates between Object values. |
|
static
|
ofObject(T target,
Property<T,V> property,
TypeEvaluator<V> evaluator,
V... values)
Constructs and returns an ObjectAnimator that animates between Object values. |
|
static ObjectAnimator |
ofPropertyValuesHolder(Object target,
PropertyValuesHolder... values)
Constructs and returns an ObjectAnimator that animates between the sets of values specified in PropertyValueHolder objects. |
|
ObjectAnimator |
setDuration(long duration)
Sets the length of the animation. |
|
void |
setFloatValues(float... values)
Sets float values that will be animated between. |
|
void |
setIntValues(int... values)
Sets int values that will be animated between. |
|
void |
setObjectValues(Object... values)
Sets the values to animate between for this animation. |
|
void |
setProperty(Property property)
Sets the property that will be animated. |
|
void |
setPropertyName(String propertyName)
Sets the name of the property that will be animated. |
|
void |
setTarget(Object target)
Sets the target object whose property will be animated by this animation |
|
void |
setupEndValues()
This method tells the object to use appropriate information to extract ending values for the animation. |
|
void |
setupStartValues()
This method tells the object to use appropriate information to extract starting values for the animation. |
|
void |
start()
Starts this animation. |
|
String |
toString()
|
|
| Methods inherited from class com.nineoldandroids.animation.ValueAnimator |
|---|
addUpdateListener, cancel, clearAllAnimations, end, getAnimatedFraction, getAnimatedValue, getAnimatedValue, getCurrentAnimationsCount, getCurrentPlayTime, getDuration, getFrameDelay, getInterpolator, getRepeatCount, getRepeatMode, getStartDelay, getValues, isRunning, isStarted, ofFloat, ofInt, ofObject, ofPropertyValuesHolder, removeAllUpdateListeners, removeUpdateListener, reverse, setCurrentPlayTime, setEvaluator, setFrameDelay, setInterpolator, setRepeatCount, setRepeatMode, setStartDelay, setValues |
| Methods inherited from class com.nineoldandroids.animation.Animator |
|---|
addListener, getListeners, removeAllListeners, removeListener |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectAnimator()
| Method Detail |
|---|
public void setPropertyName(String propertyName)
foo will result
in a call to the function setFoo() on the target object. If either
valueFrom or valueTo is null, then a getter function will
also be derived and called.
For best performance of the mechanism that calls the setter function determined by the
name of the property being animated, use float or int typed values,
and make the setter function for those properties have a void return value. This
will cause the code to take an optimized path for these constrained circumstances. Other
property types and return types will work, but will have more overhead in processing
the requests due to normal reflection mechanisms.
Note that the setter function derived from this property name
must take the same parameter type as the
valueFrom and valueTo properties, otherwise the call to
the setter function will fail.
If this ObjectAnimator has been set up to animate several properties together, using more than one PropertyValuesHolder objects, then setting the propertyName simply sets the propertyName in the first of those PropertyValuesHolder objects.
propertyName - The name of the property being animated. Should not be null.public void setProperty(Property property)
setPropertyName(String) method. Animations should
be set up to use one or the other, not both.
property - The property being animated. Should not be null.public String getPropertyName()
foo will result
in a call to the function setFoo() on the target object. If either
valueFrom or valueTo is null, then a getter function will
also be derived and called.
public static ObjectAnimator ofInt(Object target,
String propertyName,
int... values)
target - The object whose property is to be animated. This object should
have a public method on it called setName(), where name is
the value of the propertyName parameter.propertyName - The name of the property being animated.values - A set of values that the animation will animate between over time.
public static <T> ObjectAnimator ofInt(T target,
Property<T,Integer> property,
int... values)
target - The object whose property is to be animated.property - The property being animated.values - A set of values that the animation will animate between over time.
public static ObjectAnimator ofFloat(Object target,
String propertyName,
float... values)
target - The object whose property is to be animated. This object should
have a public method on it called setName(), where name is
the value of the propertyName parameter.propertyName - The name of the property being animated.values - A set of values that the animation will animate between over time.
public static <T> ObjectAnimator ofFloat(T target,
Property<T,Float> property,
float... values)
target - The object whose property is to be animated.property - The property being animated.values - A set of values that the animation will animate between over time.
public static ObjectAnimator ofObject(Object target,
String propertyName,
TypeEvaluator evaluator,
Object... values)
target - The object whose property is to be animated. This object should
have a public method on it called setName(), where name is
the value of the propertyName parameter.propertyName - The name of the property being animated.evaluator - A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values - A set of values that the animation will animate between over time.
public static <T,V> ObjectAnimator ofObject(T target,
Property<T,V> property,
TypeEvaluator<V> evaluator,
V... values)
target - The object whose property is to be animated.property - The property being animated.evaluator - A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values - A set of values that the animation will animate between over time.
public static ObjectAnimator ofPropertyValuesHolder(Object target,
PropertyValuesHolder... values)
PropertyValueHolder objects. This variant should be used when animating
several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows
you to associate a set of animation values with a property name.
target - The object whose property is to be animated. Depending on how the
PropertyValuesObjects were constructed, the target object should either have the Property objects used to construct the PropertyValuesHolder objects or (if the
PropertyValuesHOlder objects were created with property names) the target object should have
public methods on it called setName(), where name is the name of
the property passed in as the propertyName parameter for each of the
PropertyValuesHolder objects.values - A set of PropertyValuesHolder objects whose values will be animated between
over time.
public void setIntValues(int... values)
ValueAnimatorIf there are already multiple sets of values defined for this ValueAnimator via more than one PropertyValuesHolder object, this method will set the values for the first of those objects.
setIntValues in class ValueAnimatorvalues - A set of values that the animation will animate between over time.public void setFloatValues(float... values)
ValueAnimatorIf there are already multiple sets of values defined for this ValueAnimator via more than one PropertyValuesHolder object, this method will set the values for the first of those objects.
setFloatValues in class ValueAnimatorvalues - A set of values that the animation will animate between over time.public void setObjectValues(Object... values)
ValueAnimatorIf there are already multiple sets of values defined for this ValueAnimator via more than one PropertyValuesHolder object, this method will set the values for the first of those objects.
There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate between these value objects. ValueAnimator only knows how to interpolate between the primitive types specified in the other setValues() methods.
setObjectValues in class ValueAnimatorvalues - The set of values to animate between.public void start()
AnimatorAnimator.AnimatorListener.onAnimationStart(Animator) for any listeners of this animator.
The animation started by calling this method will be run on the thread that called this method. This thread should have a Looper on it (a runtime exception will be thrown if this is not the case). Also, if the animation will animate properties of objects in the view hierarchy, then the calling thread should be the UI thread for that view hierarchy.
start in class ValueAnimatorpublic ObjectAnimator setDuration(long duration)
setDuration in class ValueAnimatorduration - The length of the animation, in milliseconds.
ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start().public Object getTarget()
public void setTarget(Object target)
setTarget in class Animatortarget - The object being animatedpublic void setupStartValues()
Animator
setupStartValues in class Animatorpublic void setupEndValues()
Animator
setupEndValues in class Animatorpublic ObjectAnimator clone()
clone in class ValueAnimatorpublic String toString()
toString in class ValueAnimator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||