-
public final class ViewPropertyAnimatorCompat
-
-
Method Summary
Modifier and Type Method Description ViewPropertyAnimatorCompat
setDuration(long value)
Sets the duration for the underlying animator that animates the requested properties.By default, the animator uses the default value for ValueAnimator. ViewPropertyAnimatorCompat
alpha(float value)
This method will cause the View's alpha
property to be animated to thespecified value.ViewPropertyAnimatorCompat
alphaBy(float value)
This method will cause the View's alpha
property to be animated by thespecified value.ViewPropertyAnimatorCompat
translationX(float value)
This method will cause the View's translationX
property to be animated to thespecified value.ViewPropertyAnimatorCompat
translationY(float value)
This method will cause the View's translationY
property to be animated to thespecified value.ViewPropertyAnimatorCompat
withEndAction(Runnable runnable)
Specifies an action to take place when the next animation ends. long
getDuration()
Returns the current duration of property animations. ViewPropertyAnimatorCompat
setInterpolator(Interpolator value)
Sets the interpolator for the underlying animator that animates the requested properties.By default, the animator uses the default interpolator for ValueAnimator. Interpolator
getInterpolator()
Returns the timing interpolator that this animation uses. ViewPropertyAnimatorCompat
setStartDelay(long value)
Sets the startDelay for the underlying animator that animates the requested properties.By default, the animator uses the default value for ValueAnimator. long
getStartDelay()
Returns the current startDelay of property animations. ViewPropertyAnimatorCompat
rotation(float value)
This method will cause the View's rotation
property to be animated to thespecified value.ViewPropertyAnimatorCompat
rotationBy(float value)
This method will cause the View's rotation
property to be animated by thespecified value.ViewPropertyAnimatorCompat
rotationX(float value)
This method will cause the View's rotationX
property to be animated to thespecified value.ViewPropertyAnimatorCompat
rotationXBy(float value)
This method will cause the View's rotationX
property to be animated by thespecified value.ViewPropertyAnimatorCompat
rotationY(float value)
This method will cause the View's rotationY
property to be animated to thespecified value.ViewPropertyAnimatorCompat
rotationYBy(float value)
This method will cause the View's rotationY
property to be animated by thespecified value.ViewPropertyAnimatorCompat
scaleX(float value)
This method will cause the View's scaleX
property to be animated to thespecified value.ViewPropertyAnimatorCompat
scaleXBy(float value)
This method will cause the View's scaleX
property to be animated by thespecified value.ViewPropertyAnimatorCompat
scaleY(float value)
This method will cause the View's scaleY
property to be animated to thespecified value.ViewPropertyAnimatorCompat
scaleYBy(float value)
This method will cause the View's scaleY
property to be animated by thespecified value.void
cancel()
Cancels all property animations that are currently running or pending. ViewPropertyAnimatorCompat
x(float value)
This method will cause the View's x
property to be animated to thespecified value.ViewPropertyAnimatorCompat
xBy(float value)
This method will cause the View's x
property to be animated by thespecified value.ViewPropertyAnimatorCompat
y(float value)
This method will cause the View's y
property to be animated to thespecified value.ViewPropertyAnimatorCompat
yBy(float value)
This method will cause the View's y
property to be animated by thespecified value.ViewPropertyAnimatorCompat
translationXBy(float value)
This method will cause the View's translationX
property to be animated by thespecified value.ViewPropertyAnimatorCompat
translationYBy(float value)
This method will cause the View's translationY
property to be animated by thespecified value.ViewPropertyAnimatorCompat
translationZBy(float value)
This method will cause the View's translationZ
property to be animated by thespecified value.ViewPropertyAnimatorCompat
translationZ(float value)
This method will cause the View's translationZ
property to be animated to thespecified value.ViewPropertyAnimatorCompat
z(float value)
This method will cause the View's z
property to be animated to thespecified value.ViewPropertyAnimatorCompat
zBy(float value)
This method will cause the View's z
property to be animated by thespecified value.void
start()
Starts the currently pending property animations immediately. ViewPropertyAnimatorCompat
withLayer()
The View associated with this ViewPropertyAnimator will have its layer type set to LAYER_TYPE_HARDWARE for the duration of the next animation. ViewPropertyAnimatorCompat
withStartAction(Runnable runnable)
Specifies an action to take place when the next animation runs. ViewPropertyAnimatorCompat
setListener(ViewPropertyAnimatorListener listener)
Sets a listener for events in the underlying Animators that run the propertyanimations. ViewPropertyAnimatorCompat
setUpdateListener(ViewPropertyAnimatorUpdateListener listener)
Sets a listener for update events in the underlying Animator that runsthe property animations. -
-
Method Detail
-
setDuration
ViewPropertyAnimatorCompat setDuration(long value)
Sets the duration for the underlying animator that animates the requested properties.By default, the animator uses the default value for ValueAnimator. Calling this methodwill cause the declared value to be used instead.
- Parameters:
value
- The length of ensuing property animations, in milliseconds.
-
alpha
ViewPropertyAnimatorCompat alpha(float value)
This method will cause the View's
alpha
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
alphaBy
ViewPropertyAnimatorCompat alphaBy(float value)
This method will cause the View's
alpha
property to be animated by thespecified 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.
-
translationX
ViewPropertyAnimatorCompat translationX(float value)
This method will cause the View's
translationX
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
translationY
ViewPropertyAnimatorCompat translationY(float value)
This method will cause the View's
translationY
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
withEndAction
ViewPropertyAnimatorCompat withEndAction(Runnable runnable)
Specifies an action to take place when the next animation ends. The action is onlyrun if the animation ends normally; if the ViewPropertyAnimator is canceled duringthat animation, the runnable will not run.This method, along with withStartAction, is intended to help facilitatechoreographing ViewPropertyAnimator animations with other animations or actionsin the application.
For example, the following code animates a view to x=200 and then back to 0:
Runnable endAction = new Runnable() { public void run() { view.animate().x(0); } }; view.animate().x(200).withEndAction(endAction);
For API 14 and 15, this method will run by settinga listener on the ViewPropertyAnimatorCompat object and running the actionin that listener's onAnimationEnd method.
- Parameters:
runnable
- The action to run when the next animation ends.
-
getDuration
long getDuration()
Returns the current duration of property animations. If the duration was set on thisobject, that value is returned. Otherwise, the default value of the underlying Animatoris returned.
-
setInterpolator
ViewPropertyAnimatorCompat setInterpolator(Interpolator value)
Sets the interpolator for the underlying animator that animates the requested properties.By default, the animator uses the default interpolator for ValueAnimator. Calling this methodwill cause the declared object to be used instead.
- Parameters:
value
- The TimeInterpolator to be used for ensuing property animations.
-
getInterpolator
Interpolator getInterpolator()
Returns the timing interpolator that this animation uses.
-
setStartDelay
ViewPropertyAnimatorCompat setStartDelay(long value)
Sets the startDelay for the underlying animator that animates the requested properties.By default, the animator uses the default value for ValueAnimator. Calling this methodwill cause the declared value to be used instead.
- Parameters:
value
- The delay of ensuing property animations, in milliseconds.
-
getStartDelay
long getStartDelay()
Returns the current startDelay of property animations. If the startDelay was set on thisobject, that value is returned. Otherwise, the default value of the underlying Animatoris returned.
-
rotation
ViewPropertyAnimatorCompat rotation(float value)
This method will cause the View's
rotation
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
rotationBy
ViewPropertyAnimatorCompat rotationBy(float value)
This method will cause the View's
rotation
property to be animated by thespecified 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.
-
rotationX
ViewPropertyAnimatorCompat rotationX(float value)
This method will cause the View's
rotationX
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
rotationXBy
ViewPropertyAnimatorCompat rotationXBy(float value)
This method will cause the View's
rotationX
property to be animated by thespecified 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.
-
rotationY
ViewPropertyAnimatorCompat rotationY(float value)
This method will cause the View's
rotationY
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
rotationYBy
ViewPropertyAnimatorCompat rotationYBy(float value)
This method will cause the View's
rotationY
property to be animated by thespecified 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.
-
scaleX
ViewPropertyAnimatorCompat scaleX(float value)
This method will cause the View's
scaleX
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
scaleXBy
ViewPropertyAnimatorCompat scaleXBy(float value)
This method will cause the View's
scaleX
property to be animated by thespecified 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.
-
scaleY
ViewPropertyAnimatorCompat scaleY(float value)
This method will cause the View's
scaleY
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
scaleYBy
ViewPropertyAnimatorCompat scaleYBy(float value)
This method will cause the View's
scaleY
property to be animated by thespecified 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.
-
cancel
void cancel()
Cancels all property animations that are currently running or pending.
-
x
ViewPropertyAnimatorCompat x(float value)
This method will cause the View's
x
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
xBy
ViewPropertyAnimatorCompat xBy(float value)
This method will cause the View's
x
property to be animated by thespecified 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.
-
y
ViewPropertyAnimatorCompat y(float value)
This method will cause the View's
y
property to be animated to thespecified value. Animations already running on the property will be canceled.- Parameters:
value
- The value to be animated to.
-
yBy
ViewPropertyAnimatorCompat yBy(float value)
This method will cause the View's
y
property to be animated by thespecified 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.
-
translationXBy
ViewPropertyAnimatorCompat translationXBy(float value)
This method will cause the View's
translationX
property to be animated by thespecified 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.
-
translationYBy
ViewPropertyAnimatorCompat translationYBy(float value)
This method will cause the View's
translationY
property to be animated by thespecified 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.
-
translationZBy
ViewPropertyAnimatorCompat translationZBy(float value)
This method will cause the View's
translationZ
property to be animated by thespecified value. Animations already running on the property will be canceled.Prior to API 21, this method will do nothing.
- Parameters:
value
- The amount to be animated by, as an offset from the current value.
-
translationZ
ViewPropertyAnimatorCompat translationZ(float value)
This method will cause the View's
translationZ
property to be animated to thespecified value. Animations already running on the property will be canceled.Prior to API 21, this method will do nothing.
- Parameters:
value
- The amount to be animated by, as an offset from the current value.
-
z
ViewPropertyAnimatorCompat z(float value)
This method will cause the View's
z
property to be animated to thespecified value. Animations already running on the property will be canceled.Prior to API 21, this method will do nothing.
- Parameters:
value
- The amount to be animated by, as an offset from the current value.
-
zBy
ViewPropertyAnimatorCompat zBy(float value)
This method will cause the View's
z
property to be animated by thespecified value. Animations already running on the property will be canceled.Prior to API 21, this method will do nothing.
- Parameters:
value
- The amount to be animated by, as an offset from the current value.
-
start
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 whenthe next event is processed by the hierarchy, which is when the animations would beginotherwise), then this method can be used.
-
withLayer
ViewPropertyAnimatorCompat withLayer()
The View associated with this ViewPropertyAnimator will have its layer type set to LAYER_TYPE_HARDWARE for the duration of the next animation.As stated in the documentation for LAYER_TYPE_HARDWARE,the actual type of layer used internally depends on the runtime situation of theview. If the activity and this view are hardware-accelerated, then the layer will beaccelerated as well. If the activity or the view is not accelerated, then the layer willeffectively be the same as LAYER_TYPE_SOFTWARE.
This state is not persistent, either on the View or on this ViewPropertyAnimator: thelayer type of the View will be restored when the animation ends to what it was when thismethod was called, and this setting on ViewPropertyAnimator is only valid for the nextanimation. Note that calling this method and then independently setting the layer type ofthe View (by a direct call to setLayerType) will result in someinconsistency, including having the layer type restored to its pre-withLayer()value when the animation ends.
For API 14 and 15, this method will run by settinga listener on the ViewPropertyAnimatorCompat object, setting a hardware layer inthe listener's onAnimationStart method,and then restoring the orignal layer type in the listener's onAnimationEnd method.
-
withStartAction
ViewPropertyAnimatorCompat withStartAction(Runnable runnable)
Specifies an action to take place when the next animation runs. If there is a startDelay set on this ViewPropertyAnimator, then theaction will run after that startDelay expires, when the actual animation begins.This method, along with withEndAction, is intended to help facilitatechoreographing ViewPropertyAnimator animations with other animations or actionsin the application.
For API 14 and 15, this method will run by settinga listener on the ViewPropertyAnimatorCompat object and running the actionin that listener's onAnimationStart method.
- Parameters:
runnable
- The action to run when the next animation starts.
-
setListener
ViewPropertyAnimatorCompat setListener(ViewPropertyAnimatorListener listener)
Sets a listener for events in the underlying Animators that run the propertyanimations.
- Parameters:
listener
- The listener to be called with AnimatorListener events.
-
setUpdateListener
ViewPropertyAnimatorCompat setUpdateListener(ViewPropertyAnimatorUpdateListener listener)
Sets a listener for update events in the underlying Animator that runsthe property animations.
Prior to API 19, this method will do nothing.
- Parameters:
listener
- The listener to be called with update events.
-
-
-
-