public final class ViewPropertyAnimatorCompat extends Object
Modifier and Type | Method and Description |
---|---|
ViewPropertyAnimatorCompat |
alpha(float value)
This method will cause the View's
alpha property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
alphaBy(float value)
This method will cause the View's
alpha property to be animated by the
specified value. |
void |
cancel()
Cancels all property animations that are currently running or pending.
|
long |
getDuration()
Returns the current duration of property animations.
|
Interpolator |
getInterpolator()
Returns the timing interpolator that this animation uses.
|
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 the
specified value. |
ViewPropertyAnimatorCompat |
rotationBy(float value)
This method will cause the View's
rotation property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
rotationX(float value)
This method will cause the View's
rotationX property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
rotationXBy(float value)
This method will cause the View's
rotationX property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
rotationY(float value)
This method will cause the View's
rotationY property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
rotationYBy(float value)
This method will cause the View's
rotationY property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
scaleX(float value)
This method will cause the View's
scaleX property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
scaleXBy(float value)
This method will cause the View's
scaleX property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
scaleY(float value)
This method will cause the View's
scaleY property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
scaleYBy(float value)
This method will cause the View's
scaleY property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
setDuration(long value)
Sets the duration for the underlying animator that animates the requested properties.
|
ViewPropertyAnimatorCompat |
setInterpolator(Interpolator value)
Sets the interpolator for the underlying animator that animates the requested properties.
|
ViewPropertyAnimatorCompat |
setListener(ViewPropertyAnimatorListener listener)
Sets a listener for events in the underlying Animators that run the property
animations.
|
ViewPropertyAnimatorCompat |
setStartDelay(long value)
Sets the startDelay for the underlying animator that animates the requested properties.
|
ViewPropertyAnimatorCompat |
setUpdateListener(ViewPropertyAnimatorUpdateListener listener)
Sets a listener for update events in the underlying Animator that runs
the property animations.
|
void |
start()
Starts the currently pending property animations immediately.
|
ViewPropertyAnimatorCompat |
translationX(float value)
This method will cause the View's
translationX property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
translationXBy(float value)
This method will cause the View's
translationX property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
translationY(float value)
This method will cause the View's
translationY property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
translationYBy(float value)
This method will cause the View's
translationY property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
translationZ(float value)
This method will cause the View's
translationZ property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
translationZBy(float value)
This method will cause the View's
translationZ property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
withEndAction(Runnable runnable)
Specifies an action to take place when the next animation ends.
|
ViewPropertyAnimatorCompat |
withLayer()
The View associated with this ViewPropertyAnimator will have its
layer type set to
ViewCompat.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 |
x(float value)
This method will cause the View's
x property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
xBy(float value)
This method will cause the View's
x property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
y(float value)
This method will cause the View's
y property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
yBy(float value)
This method will cause the View's
y property to be animated by the
specified value. |
ViewPropertyAnimatorCompat |
z(float value)
This method will cause the View's
z property to be animated to the
specified value. |
ViewPropertyAnimatorCompat |
zBy(float value)
This method will cause the View's
z property to be animated by the
specified value. |
public ViewPropertyAnimatorCompat setDuration(long value)
Prior to API 14, this method will do nothing.
value
- The length of ensuing property animations, in milliseconds. The value
cannot be negative.public ViewPropertyAnimatorCompat alpha(float value)
alpha
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat alphaBy(float value)
alpha
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat translationX(float value)
translationX
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat translationY(float value)
translationY
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat withEndAction(Runnable runnable)
withStartAction(Runnable)
, 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);
Prior to API 14, this method will run the action immediately.
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 ViewPropertyAnimatorListener.onAnimationEnd(View)
method.
runnable
- The action to run when the next animation ends.public long getDuration()
Prior to API 14, this method will return 0.
setDuration(long)
public ViewPropertyAnimatorCompat setInterpolator(Interpolator value)
Prior to API 14, this method will do nothing.
value
- The TimeInterpolator to be used for ensuing property animations.public Interpolator getInterpolator()
Prior to API 14, this method will return null.
public ViewPropertyAnimatorCompat setStartDelay(long value)
Prior to API 14, this method will do nothing.
value
- The delay of ensuing property animations, in milliseconds. The value
cannot be negative.public long getStartDelay()
Prior to API 14, this method will return 0.
setStartDelay(long)
public ViewPropertyAnimatorCompat rotation(float value)
rotation
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat rotationBy(float value)
rotation
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat rotationX(float value)
rotationX
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat rotationXBy(float value)
rotationX
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat rotationY(float value)
rotationY
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat rotationYBy(float value)
rotationY
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat scaleX(float value)
scaleX
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat scaleXBy(float value)
scaleX
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat scaleY(float value)
scaleY
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat scaleYBy(float value)
scaleY
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public void cancel()
public ViewPropertyAnimatorCompat x(float value)
x
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat xBy(float value)
x
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat y(float value)
y
property to be animated to the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The value to be animated to.public ViewPropertyAnimatorCompat yBy(float value)
y
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat translationXBy(float value)
translationX
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat translationYBy(float value)
translationY
property to be animated by the
specified value. Animations already running on the property will be canceled.
Prior to API 14, this method will do nothing.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat translationZBy(float value)
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.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat translationZ(float value)
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.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat z(float value)
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.
value
- The amount to be animated by, as an offset from the current value.public ViewPropertyAnimatorCompat zBy(float value)
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.
value
- The amount to be animated by, as an offset from the current value.public void start()
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.
Prior to API 14, this method will do nothing.
public ViewPropertyAnimatorCompat withLayer()
layer type
set to
ViewCompat.LAYER_TYPE_HARDWARE
for the duration of the next animation.
As stated in the documentation for ViewCompat.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 ViewCompat.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
ViewCompat.setLayerType(View, int, android.graphics.Paint)
) will result in some
inconsistency, including having the layer type restored to its pre-withLayer()
value when the animation ends.
Prior to API 14, this method will do nothing.
For API 14 and 15, this method will run by setting
a listener on the ViewPropertyAnimatorCompat object, setting a hardware layer in
the listener's ViewPropertyAnimatorListener.onAnimationStart(View)
method,
and then restoring the orignal layer type in the listener's
ViewPropertyAnimatorListener.onAnimationEnd(View)
method.
View.setLayerType(int, android.graphics.Paint)
public ViewPropertyAnimatorCompat withStartAction(Runnable runnable)
startDelay
set on this ViewPropertyAnimator, then the
action will run after that startDelay expires, when the actual animation begins.
This method, along with withEndAction(Runnable)
, is intended to help facilitate
choreographing ViewPropertyAnimator animations with other animations or actions
in the application.
Prior to API 14, this method will run the action immediately.
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 ViewPropertyAnimatorListener.onAnimationStart(View)
method.
runnable
- The action to run when the next animation starts.public ViewPropertyAnimatorCompat setListener(ViewPropertyAnimatorListener listener)
Prior to API 14, this method will do nothing.
listener
- The listener to be called with AnimatorListener events. A value of
null
removes any existing listener.public ViewPropertyAnimatorCompat setUpdateListener(ViewPropertyAnimatorUpdateListener listener)
Prior to API 19, this method will do nothing.
listener
- The listener to be called with update events. A value of
null
removes any existing listener.