ViewPropertyAnimatorCompat
public final class ViewPropertyAnimatorCompat
Summary
Public methods |
|
|---|---|
@NonNull ViewPropertyAnimatorCompat |
alpha(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
alphaBy(float value)This method will cause the View's |
void |
cancel()Cancels all property animations that are currently running or pending. |
long |
Returns the current duration of property animations. |
@Nullable Interpolator |
Returns the timing interpolator that this animation uses. |
long |
Returns the current startDelay of property animations. |
@NonNull ViewPropertyAnimatorCompat |
rotation(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
rotationBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
rotationX(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
rotationXBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
rotationY(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
rotationYBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
scaleX(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
scaleXBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
scaleY(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
scaleYBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
setDuration(long value)Sets the duration for the underlying animator that animates the requested properties. |
@NonNull ViewPropertyAnimatorCompat |
setInterpolator(@Nullable Interpolator value)Sets the interpolator for the underlying animator that animates the requested properties. |
@NonNull ViewPropertyAnimatorCompat |
setListener(@Nullable ViewPropertyAnimatorListener listener)Sets a listener for events in the underlying Animators that run the property animations. |
@NonNull ViewPropertyAnimatorCompat |
setStartDelay(long value)Sets the startDelay for the underlying animator that animates the requested properties. |
@NonNull ViewPropertyAnimatorCompat |
Sets a listener for update events in the underlying Animator that runs the property animations. |
void |
start()Starts the currently pending property animations immediately. |
@NonNull ViewPropertyAnimatorCompat |
translationX(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
translationXBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
translationY(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
translationYBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
translationZ(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
translationZBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
withEndAction(@NonNull Runnable runnable)Specifies an action to take place when the next animation ends. |
@NonNull ViewPropertyAnimatorCompat |
The View associated with this ViewPropertyAnimator will have its |
@NonNull ViewPropertyAnimatorCompat |
withStartAction(@NonNull Runnable runnable)Specifies an action to take place when the next animation runs. |
@NonNull ViewPropertyAnimatorCompat |
x(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
xBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
y(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
yBy(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
z(float value)This method will cause the View's |
@NonNull ViewPropertyAnimatorCompat |
zBy(float value)This method will cause the View's |
Public methods
alpha
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
alphaBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
cancel
public void cancel()
Cancels all property animations that are currently running or pending.
getDuration
public 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 | |
|---|---|
long |
The duration of animations, in milliseconds. |
| See also | |
|---|---|
setDuration |
getInterpolator
public @Nullable Interpolator getInterpolator()
Returns the timing interpolator that this animation uses.
| Returns | |
|---|---|
@Nullable Interpolator |
The timing interpolator for this animation. |
getStartDelay
public 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 | |
|---|---|
long |
The startDelay of animations, in milliseconds. |
| See also | |
|---|---|
setStartDelay |
rotation
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
rotationBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
rotationX
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
rotationXBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
rotationY
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
rotationYBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
scaleX
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
scaleXBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
scaleY
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
scaleYBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
setDuration
public @NonNull 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 method will cause the declared value to be used instead.
| Parameters | |
|---|---|
long value |
The length of ensuing property animations, in milliseconds. The value cannot be negative. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
setInterpolator
public @NonNull ViewPropertyAnimatorCompat setInterpolator(@Nullable 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 method will cause the declared object to be used instead.
| Parameters | |
|---|---|
@Nullable Interpolator value |
The TimeInterpolator to be used for ensuing property animations. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
setListener
public @NonNull ViewPropertyAnimatorCompat setListener(@Nullable ViewPropertyAnimatorListener listener)
Sets a listener for events in the underlying Animators that run the property animations.
| Parameters | |
|---|---|
@Nullable ViewPropertyAnimatorListener listener |
The listener to be called with AnimatorListener events. A value of |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
setStartDelay
public @NonNull 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 method will cause the declared value to be used instead.
| Parameters | |
|---|---|
long value |
The delay of ensuing property animations, in milliseconds. The value cannot be negative. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
setUpdateListener
public @NonNull ViewPropertyAnimatorCompat setUpdateListener(@Nullable ViewPropertyAnimatorUpdateListener listener)
Sets a listener for update events in the underlying Animator that runs the property animations.
| Parameters | |
|---|---|
@Nullable ViewPropertyAnimatorUpdateListener listener |
The listener to be called with update events. A value of |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
start
public 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.
translationX
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
translationXBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
translationY
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
translationYBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
translationZ
public @NonNull ViewPropertyAnimatorCompat translationZ(float value)
This method will cause the View's translationZ property to be animated to the specified value. Animations already running on the property will be canceled.
Prior to API 21, this method will do nothing.
| Parameters | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
translationZBy
public @NonNull ViewPropertyAnimatorCompat translationZBy(float value)
This method will cause the View's translationZ property to be animated by the specified value. Animations already running on the property will be canceled.
Prior to API 21, this method will do nothing.
| Parameters | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
withEndAction
public @NonNull ViewPropertyAnimatorCompat withEndAction(@NonNull Runnable runnable)
Specifies an action to take place when the next animation ends. The action is only run if the animation ends normally; if the ViewPropertyAnimator is canceled during that animation, the runnable will not run. This method, along with withStartAction, is intended to help facilitate choreographing ViewPropertyAnimator animations with other animations or actions in 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 setting a listener on the ViewPropertyAnimatorCompat object and running the action in that listener's onAnimationEnd method.
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
withLayer
public @NonNull 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 the view. If the activity and this view are hardware-accelerated, then the layer will be accelerated as well. If the activity or the view is not accelerated, then the layer will effectively be the same as LAYER_TYPE_SOFTWARE.
This state is not persistent, either on the View or on this ViewPropertyAnimator: the layer type of the View will be restored when the animation ends to what it was when this method was called, and this setting on ViewPropertyAnimator is only valid for the next animation. Note that calling this method and then independently setting the layer type of the View (by a direct call to setLayerType) will result in some inconsistency, including having the layer type restored to its pre-withLayer() value when the animation ends.
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
| See also | |
|---|---|
setLayerType |
withStartAction
public @NonNull ViewPropertyAnimatorCompat withStartAction(@NonNull Runnable runnable)
Specifies an action to take place when the next animation runs. If there is a startDelay set on this ViewPropertyAnimator, then the action will run after that startDelay expires, when the actual animation begins. This method, along with withEndAction, is intended to help facilitate choreographing ViewPropertyAnimator animations with other animations or actions in the application.
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
x
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
xBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
y
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The value to be animated to. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
yBy
public @NonNull ViewPropertyAnimatorCompat 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 | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
z
public @NonNull ViewPropertyAnimatorCompat z(float value)
This method will cause the View's z property to be animated to the specified value. Animations already running on the property will be canceled.
Prior to API 21, this method will do nothing.
| Parameters | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |
zBy
public @NonNull ViewPropertyAnimatorCompat zBy(float value)
This method will cause the View's z property to be animated by the specified value. Animations already running on the property will be canceled.
Prior to API 21, this method will do nothing.
| Parameters | |
|---|---|
float value |
The amount to be animated by, as an offset from the current value. |
| Returns | |
|---|---|
@NonNull ViewPropertyAnimatorCompat |
This object, allowing calls to methods in this class to be chained. |