Android Animation for Titanium
Provides access to Honeycomb+ Animation APIs
|
Use this to animate native View properties when faced with any of these circumstances: More...
Inherits Animator_.
Public Member Functions | |
.method.getProperty int | getEvaluator () |
Gets the evaluator. More... | |
.method.setProperty void | setEvaluator (int evaluator) |
.method void | reverse () |
.method.getProperty String | getPropertyName () |
.method.setProperty void | setPropertyName (String propertyName) |
.method.setProperty void | setIntValues (Object...values) |
If you are animating a property whose data type is int , you may use this setter method to animate between one or more values. More... | |
.method.setProperty void | setFloatValues (Object...values) |
If you are animating a property whose data type is float , you may use this setter method to animate between one or more values. More... | |
.method.getProperty int | getRepeatCount () |
.method.setProperty void | setRepeatCount (int repeatCount) |
.method.getProperty int | getRepeatMode () |
.method.setProperty void | setRepeatMode (int repeatMode) |
.method.getProperty long | getDuration () |
.method.setProperty void | setDuration (long milliseconds) |
.method void | cancel () |
.method void | end () |
.method void | start () |
.method boolean | isRunning () |
.method boolean | isStarted () |
.method.getProperty int | getInterpolator () |
.method.setProperty void | setInterpolator (int interpolator) |
.method.setProperty void | setInterpolatorValues (Object...values) |
Sets the interpolator values. More... | |
.method.getProperty float[] | getInterpolatorValues () |
.method.getProperty Object | getTarget () |
.method.setProperty void | setTarget (Object target) |
.method.getProperty long | getStartDelay () |
.method.setProperty void | setStartDelay (long startDelay) |
Use this to animate native View properties when faced with any of these circumstances:
backgroundColor
.ViewPropertyAnimator
because its methods do not accept from values, so use this class instead.AnimatorSet
does not accept ViewPropertyAnimator
instances; you must give it instances of this class.Your first choice should always be the ViewPropertyAnimator because it is slightly more performant (according to Android), has a simpler interface and will accept values that specify units (such as "12dp"). But if any of the conditions listed above applies, then turn to this class, the ObjectAnimator
.
In actual fact, ObjectAnimator
can be used to animate the properties of any kind of object – not just Views – as long as the property has Java setter and getter methods. In Javascript, however, you only have access to the objects you create from scratch (i.e., true Javascript objects) and Titanium-based objects such as views, which (under the covers) have counterparts in Java. Many properties of Titanium objects, however, do not have true getter and setter methods in their Java counterparts, so they can't be animated directly using the ObjectAnimator
.
Therefore, when you use ObjectAnimator
to animate a Titanium view (View
, ImageView
, Label
, TableView
, etc.), we "unwrap" the view to get to the real Android View and animate that instead. And the Java class for Android View has getter and setter methods for its properties, so ObjectAnimator
works just fine with it.
This also means that the property name that you pass as the second argument to ofInt and ofFloat must be the Android property name, so being familiar with the getter and setter methods of Android View would be helpful.
The preferred way to instantiate this class is via one of the two factory methods available in the module.
var animator = module.objectAnimator.ofInt(view, "propertyName", fromVal, toVal);
or
var animator = module.objectAnimator.ofFloat(view, "propertyName", fromVal, toVal);
As you might guess, you'll use ofInt when the property you want to animate has an integer data type, while ofFloat should be used when animating a property that has a float datatype.
Since you are animating native Android properties, be aware that most integer values (and some float values) represent pixels. In this ObjectAnimator
class we do not do pixel/density calculations automatically for you, which means you cannot animate with values such as "20dp". But this module does contain a toPixels method to help you make those calculations before you pass the values to an ObjectAnimator
.
Here is an example of using ObjectAnimator
to animate a view's backgroundColor
from red to green:
var win = Ti.UI.createWindow(), view = Ti.UI.createView({ backgroundColor: "green" }), animMod = require("com.billdawson.timodules.animation"), animator = animMod.objectAnimator.ofInt(view, "backgroundColor", "red"); animator.setDuration(1000); animator.setEvaluator(animMod.ARGB_EVALUATOR); win.add(view); win.addEventListener("open", function() { animator.start(); });
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
Gets the evaluator.
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inlineinherited |
|
inline |
|
inline |
If you are animating a property whose data type is float
, you may use this setter method to animate between one or more values.
However, it's preferred that you use the ofFloat method to create the ObjectAnimator
and set its float
values all at once.
If you pass just one value here, then the animation will be from the current value to the value you give here. If you pass more than one value, then the animation will start from the first value you provide and end with the last value you provide. The two typical use cases are to provide either one value or two values. However it is possible to pass more than two values, in which case the animation will "go through" the intermediary values on its way to the final value.
We do not do pixel calculations for you, so if you are animating a pixel value be sure to use toPixels first to get the correct pixel value.
|
inlineinherited |
|
inlineinherited |
Sets the interpolator values.
|
inline |
If you are animating a property whose data type is int
, you may use this setter method to animate between one or more values.
However, it's preferred that you use the ofInt method to create the ObjectAnimator
and set its int
values all at once.
If you pass just one value here, then the animation will be from the current value to the value you give here. If you pass more than one value, then the animation will start from the first value you provide and end with the last value you provide. The two typical use cases are to provide either one value or two values. However it is possible to pass more than two values, in which case the animation will "go through" the intermediary values on its way to the final value.
If you are animating the view's backgroundColor, you can pass strings representing colors instead of integers. For example, "black", "#000", and such would be recognized and changed on the fly for you to their valid Android color integers. Besides this special case, only pass integer values. We do not do pixel calculations for you, so if you are animating a pixel value be sure to use toPixels first to get the correct pixel value.
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |