com.nineoldandroids.view
Class ViewPropertyAnimator

java.lang.Object
  extended by com.nineoldandroids.view.ViewPropertyAnimator

public abstract class ViewPropertyAnimator
extends Object

This class enables automatic and optimized animation of select properties on View objects. If only one or two properties on a View object are being animated, then using an ObjectAnimator is fine; the property setters called by ObjectAnimator are well equipped to do the right thing to set the property and invalidate the view appropriately. But if several properties are animated simultaneously, or if you just want a more convenient syntax to animate a specific property, then ViewPropertyAnimator might be more well-suited to the task.

This class may provide better performance for several simultaneous animations, because it will optimize invalidate calls to take place only once for several properties instead of each animated property independently causing its own invalidation. Also, the syntax of using this class could be easier to use because the caller need only tell the View object which property to animate, and the value to animate either to or by, and this class handles the details of configuring the underlying Animator class and starting it.

This class is not constructed by the caller, but rather by the View whose properties it will animate. Calls to View will return a reference to the appropriate ViewPropertyAnimator object for that View.


Constructor Summary
ViewPropertyAnimator()
           
 
Method Summary
abstract  ViewPropertyAnimator alpha(float value)
          This method will cause the View's alpha property to be animated to the specified value.
abstract  ViewPropertyAnimator alphaBy(float value)
          This method will cause the View's alpha property to be animated by the specified value.
static ViewPropertyAnimator animate(View view)
          This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
abstract  void cancel()
          Cancels all property animations that are currently running or pending.
abstract  long getDuration()
          Returns the current duration of property animations.
abstract  long getStartDelay()
          Returns the current startDelay of property animations.
abstract  ViewPropertyAnimator rotation(float value)
          This method will cause the View's rotation property to be animated to the specified value.
abstract  ViewPropertyAnimator rotationBy(float value)
          This method will cause the View's rotation property to be animated by the specified value.
abstract  ViewPropertyAnimator rotationX(float value)
          This method will cause the View's rotationX property to be animated to the specified value.
abstract  ViewPropertyAnimator rotationXBy(float value)
          This method will cause the View's rotationX property to be animated by the specified value.
abstract  ViewPropertyAnimator rotationY(float value)
          This method will cause the View's rotationY property to be animated to the specified value.
abstract  ViewPropertyAnimator rotationYBy(float value)
          This method will cause the View's rotationY property to be animated by the specified value.
abstract  ViewPropertyAnimator scaleX(float value)
          This method will cause the View's scaleX property to be animated to the specified value.
abstract  ViewPropertyAnimator scaleXBy(float value)
          This method will cause the View's scaleX property to be animated by the specified value.
abstract  ViewPropertyAnimator scaleY(float value)
          This method will cause the View's scaleY property to be animated to the specified value.
abstract  ViewPropertyAnimator scaleYBy(float value)
          This method will cause the View's scaleY property to be animated by the specified value.
abstract  ViewPropertyAnimator setDuration(long duration)
          Sets the duration for the underlying animator that animates the requested properties.
abstract  ViewPropertyAnimator setInterpolator(Interpolator interpolator)
          Sets the interpolator for the underlying animator that animates the requested properties.
abstract  ViewPropertyAnimator setListener(Animator.AnimatorListener listener)
          Sets a listener for events in the underlying Animators that run the property animations.
abstract  ViewPropertyAnimator setStartDelay(long startDelay)
          Sets the startDelay for the underlying animator that animates the requested properties.
abstract  void start()
          Starts the currently pending property animations immediately.
abstract  ViewPropertyAnimator translationX(float value)
          This method will cause the View's translationX property to be animated to the specified value.
abstract  ViewPropertyAnimator translationXBy(float value)
          This method will cause the View's translationX property to be animated by the specified value.
abstract  ViewPropertyAnimator translationY(float value)
          This method will cause the View's translationY property to be animated to the specified value.
abstract  ViewPropertyAnimator translationYBy(float value)
          This method will cause the View's translationY property to be animated by the specified value.
abstract  ViewPropertyAnimator x(float value)
          This method will cause the View's x property to be animated to the specified value.
abstract  ViewPropertyAnimator xBy(float value)
          This method will cause the View's x property to be animated by the specified value.
abstract  ViewPropertyAnimator y(float value)
          This method will cause the View's y property to be animated to the specified value.
abstract  ViewPropertyAnimator yBy(float value)
          This method will cause the View's y property to be animated by the specified value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewPropertyAnimator

public ViewPropertyAnimator()
Method Detail

animate

public static ViewPropertyAnimator animate(View view)
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Parameters:
view - View to animate.
Returns:
The ViewPropertyAnimator associated with this View.

setDuration

public abstract ViewPropertyAnimator setDuration(long duration)
Sets the duration for the underlying animator that animates the requested properties. By default, the animator uses the default value for ValueAnimator. Calling this method will cause the declared value to be used instead.

Parameters:
duration - The length of ensuing property animations, in milliseconds. The value cannot be negative.
Returns:
This object, allowing calls to methods in this class to be chained.

getDuration

public abstract long getDuration()
Returns the current duration of property animations. If the duration was set on this object, that value is returned. Otherwise, the default value of the underlying Animator is returned.

Returns:
The duration of animations, in milliseconds.
See Also:
setDuration(long)

getStartDelay

public abstract long getStartDelay()
Returns the current startDelay of property animations. If the startDelay was set on this object, that value is returned. Otherwise, the default value of the underlying Animator is returned.

Returns:
The startDelay of animations, in milliseconds.
See Also:
setStartDelay(long)

setStartDelay

public abstract ViewPropertyAnimator setStartDelay(long startDelay)
Sets the startDelay for the underlying animator that animates the requested properties. By default, the animator uses the default value for ValueAnimator. Calling this method will cause the declared value to be used instead.

Parameters:
startDelay - The delay of ensuing property animations, in milliseconds. The value cannot be negative.
Returns:
This object, allowing calls to methods in this class to be chained.

setInterpolator

public abstract ViewPropertyAnimator setInterpolator(Interpolator interpolator)
Sets the interpolator for the underlying animator that animates the requested properties. By default, the animator uses the default interpolator for ValueAnimator. Calling this method will cause the declared object to be used instead.

Parameters:
interpolator - The TimeInterpolator to be used for ensuing property animations.
Returns:
This object, allowing calls to methods in this class to be chained.

setListener

public abstract ViewPropertyAnimator setListener(Animator.AnimatorListener listener)
Sets a listener for events in the underlying Animators that run the property animations.

Parameters:
listener - The listener to be called with AnimatorListener events.
Returns:
This object, allowing calls to methods in this class to be chained.

start

public abstract void start()
Starts the currently pending property animations immediately. Calling start() is optional because all animations start automatically at the next opportunity. However, if the animations are needed to start immediately and synchronously (not at the time when the next event is processed by the hierarchy, which is when the animations would begin otherwise), then this method can be used.


cancel

public abstract void cancel()
Cancels all property animations that are currently running or pending.


x

public abstract ViewPropertyAnimator x(float value)
This method will cause the View's x property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setX(float)

xBy

public abstract ViewPropertyAnimator xBy(float value)
This method will cause the View's x property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setX(float)

y

public abstract ViewPropertyAnimator y(float value)
This method will cause the View's y property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setY(float)

yBy

public abstract ViewPropertyAnimator yBy(float value)
This method will cause the View's y property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setY(float)

rotation

public abstract ViewPropertyAnimator rotation(float value)
This method will cause the View's rotation property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotation(float)

rotationBy

public abstract ViewPropertyAnimator rotationBy(float value)
This method will cause the View's rotation property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotation(float)

rotationX

public abstract ViewPropertyAnimator rotationX(float value)
This method will cause the View's rotationX property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotationX(float)

rotationXBy

public abstract ViewPropertyAnimator rotationXBy(float value)
This method will cause the View's rotationX property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotationX(float)

rotationY

public abstract ViewPropertyAnimator rotationY(float value)
This method will cause the View's rotationY property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotationY(float)

rotationYBy

public abstract ViewPropertyAnimator rotationYBy(float value)
This method will cause the View's rotationY property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setRotationY(float)

translationX

public abstract ViewPropertyAnimator translationX(float value)
This method will cause the View's translationX property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setTranslationX(float)

translationXBy

public abstract ViewPropertyAnimator translationXBy(float value)
This method will cause the View's translationX property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setTranslationX(float)

translationY

public abstract ViewPropertyAnimator translationY(float value)
This method will cause the View's translationY property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setTranslationY(float)

translationYBy

public abstract ViewPropertyAnimator translationYBy(float value)
This method will cause the View's translationY property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setTranslationY(float)

scaleX

public abstract ViewPropertyAnimator scaleX(float value)
This method will cause the View's scaleX property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setScaleX(float)

scaleXBy

public abstract ViewPropertyAnimator scaleXBy(float value)
This method will cause the View's scaleX property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setScaleX(float)

scaleY

public abstract ViewPropertyAnimator scaleY(float value)
This method will cause the View's scaleY property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setScaleY(float)

scaleYBy

public abstract ViewPropertyAnimator scaleYBy(float value)
This method will cause the View's scaleY property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setScaleY(float)

alpha

public abstract ViewPropertyAnimator alpha(float value)
This method will cause the View's alpha property to be animated to the specified value. Animations already running on the property will be canceled.

Parameters:
value - The value to be animated to.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setAlpha(float)

alphaBy

public abstract ViewPropertyAnimator alphaBy(float value)
This method will cause the View's alpha property to be animated by the specified value. Animations already running on the property will be canceled.

Parameters:
value - The amount to be animated by, as an offset from the current value.
Returns:
This object, allowing calls to methods in this class to be chained.
See Also:
View#setAlpha(float)