java.lang.Object | |
↳ | com.neomades.ui.animation.Animation |
This class provides functionalities to animate views. Animations are combinations of translations, rotations, scales and fade effects.
To animate a view, create an animation with animate(View)
.
Once the animation created, various effects may be applied such as rotations,
translations, zoom, etc. To start the animation, call the start()
method.
Example of a 1s fade effect animation on an ImageLabel
:
ImageLabel image = new ImageLabel(); image.setImage("MyImage.png"); Animation animation = Animation.animate(image).setAlpha(0).setDuration(1000).start();
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Animation |
alpha(float value)
This method will change the transparency of the View from its current value
to the specified value.
| ||||||||||
Animation |
alphaBy(float value)
This method will change the transparency of the image from its current value
by the specified value.
| ||||||||||
static Animation |
animate(View view)
This method creates an Animation object which can be used to animate specific
properties on a View.
| ||||||||||
void |
cancel()
Cancels the animations if it is running.
| ||||||||||
long |
getDuration()
Returns the current duration of the animations.
| ||||||||||
long |
getStartDelay()
Returns the current startDelay of the animations.
| ||||||||||
Animation |
rotation(float value)
This method will cause the View to rotate to the specified value.
| ||||||||||
Animation |
rotationBy(float value)
This method will cause the View to rotate by the specified value.
| ||||||||||
Animation |
rotationX(float value)
This method will cause the View to rotate to the specified value around the
x-axis.
| ||||||||||
Animation |
rotationXBy(float value)
This method will cause the View to rotate by the specified value around the
x-axis.
| ||||||||||
Animation |
rotationY(float value)
This method will cause the View to rotate to the specified value around the
y-axis.
| ||||||||||
Animation |
rotationYBy(float value)
This method will cause the View to rotate by the specified value around the
y-axis.
| ||||||||||
Animation |
scaleX(float scaleFactor)
This method will cause the View to scale its width to the specified scale
factor, based on the view's original width.
| ||||||||||
Animation |
scaleXBy(float scaleFactor)
This method will cause the View to scale its width by the specified scale
factor, based on the view's current scale.
| ||||||||||
Animation |
scaleY(float scaleFactor)
This method will cause the View to scale its height to the specified scale
factor, based on the view's original height.
| ||||||||||
Animation |
scaleYBy(float scaleFactor)
This method will cause the View to scale its height by the specified scale
factor, based on the view's current scale.
| ||||||||||
Animation |
setDuration(long duration)
Sets the duration of the animation in milliseconds.
| ||||||||||
Animation |
setListener(AnimationListener listener)
Attaches a callback to listen state of this animation.
| ||||||||||
Animation |
setStartDelay(long startDelay)
Sets a startDelay for the animation.
| ||||||||||
void |
start()
Starts the animation immediately.
| ||||||||||
Animation |
translationX(float value)
This method will cause the View to translate to the specified value around
the x-axis.
| ||||||||||
Animation |
translationXBy(float value)
This method will cause the View to translate by the specified value around
the x-axis.
| ||||||||||
Animation |
translationY(float value)
This method will cause the View to translate to the specified value around
the y-axis.
| ||||||||||
Animation |
translationYBy(float value)
This method will cause the View to translate by the specified value around
the y-axis.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
This method will change the transparency of the View from its current value to the specified value. The transparency can change from 1 (opaque) to 0 (transparent).
value | The value to be animated to. |
---|
This method will change the transparency of the image from its current value by the specified value. The transparency can change from 1 (opaque) to 0 (transparent).
value | The amount to be animated by, as an offset from the current value. |
---|
This method creates an Animation object which can be used to animate specific properties on a View.
view | View to animate. |
---|
IllegalStateException | Animation has already be started or cancelled |
---|
Cancels the animations if it is running. The animations will be stopped and the view will be reseted to its original position.
Returns the current duration of the animations. If the duration was set on this object, that value is returned. Otherwise, the default value is returned.
Returns the current startDelay of the animations. If the startDelay was set on this object, that value is returned. Otherwise, the default value is returned.
This method will cause the View to rotate to the specified value. Once the View has reached its angle, calling this method with the same value on the View will have no effect.
By default the center of the rotation is the middle of the view. It can be
changed using setTransformOrigin(float, float)
.
value | The value to be animated to. |
---|
This method will cause the View to rotate by the specified value.
By default the center of the rotation is the middle of the view. It can be
changed using setTransformOrigin(float, float)
.
value | The amount to be animated by, as an offset from the current value. |
---|
This method will cause the View to rotate to the specified value around the x-axis.
By default the x-axis is in the middle of the view. Its position can be
changed using setTransformOrigin(float, float)
.
value | The value to be animated to. |
---|
This method will cause the View to rotate by the specified value around the x-axis.
By default the x-axis is in the middle of the view. Its position can be
changed using setTransformOrigin(float, float)
.
value | The amount to be animated by, as an offset from the current value. |
---|
This method will cause the View to rotate to the specified value around the y-axis.
By default the y-axis is in the middle of the view. Its position can be
changed using setTransformOrigin(float, float)
.
value | The value to be animated to. |
---|
This method will cause the View to rotate by the specified value around the y-axis.
By default the y-axis is in the middle of the view. Its position can be
changed using setTransformOrigin(float, float)
.
value | The amount to be animated by, as an offset from the current value. |
---|
This method will cause the View to scale its width to the specified scale factor, based on the view's original width.
By default the origin point of the transformation is the center of the view.
It can be changed using setTransformOrigin(float, float)
.
scaleFactor | The factor to apply to the view. A value greater than 1 will scale up the view, less than 1 will scale down the view |
---|
This method will cause the View to scale its width by the specified scale factor, based on the view's current scale.
By default the origin point of the transformation is the center of the view.
It can be changed using setTransformOrigin(float, float)
.
scaleFactor | The factor to apply to the view. A value greater than 1 will scale up the view, less than 1 will scale down the view |
---|
This method will cause the View to scale its height to the specified scale factor, based on the view's original height.
By default the origin point of the transformation is the center of the view.
It can be changed using setTransformOrigin(float, float)
.
scaleFactor | The factor to apply to the view. A value greater than 1 will scale up the view, less than 1 will scale down the view |
---|
This method will cause the View to scale its height by the specified scale factor, based on the view's current scale.
By default the origin point of the transformation is the center of the view.
It can be changed using setTransformOrigin(float, float)
.
scaleFactor | The factor to apply to the view. A value greater than 1 will scale up the view, less than 1 will scale down the view |
---|
Sets the duration of the animation in milliseconds.
duration | The length of ensuing property animations, in milliseconds. The value cannot be negative. |
---|
Attaches a callback to listen state of this animation. This can be use to chain animation starting one when an other finishes.
listener | callback to call or null |
---|
Sets a startDelay for the animation.
startDelay | The delay of ensuing property animations, in milliseconds. The value cannot be negative. |
---|
Starts the animation immediately.
This method will cause the View to translate to the specified value around the x-axis.
value | The value to be animated to. |
---|
This method will cause the View to translate by the specified value around the x-axis.
value | The amount to be animated by, as an offset from the current value. |
---|
This method will cause the View to translate to the specified value around the y-axis.
value | The value to be animated to. |
---|
This method will cause the View to translate by the specified value around the y-axis.
value | The amount to be animated by, as an offset from the current value. |
---|