Important Deprecation Notice
masterminSdkVersion="14" or higher to access the native platform animation APIs directly.repository·master·Indexed 26 days ago
https://github.com/jakewharton/nineoldandroidsA deprecated library providing access to Android 3.0 (Honeycomb) animation APIs for older Android platform versions dating back to 1.0. It serves as a drop-in replacement for the native animation API, featuring classes such as KeyframeSet for interpolated values and ViewPropertyAnimatorHC for animating View properties like alpha, rotation, and translation.
minSdkVersion="14" or higher to access the native platform animation APIs directly.You can include NineOldAndroids in your Android project using either a manual JAR inclusion or via Maven.
Manual Installation:
Download the .jar file from the GitHub downloads page and place it in your application's libs/ folder.
Maven Dependency: If you use Maven, add the following dependency to your configuration:
<dependency>
<groupId>com.nineoldandroids</groupId>
<artifactId>library</artifactId>
<version>2.4.0</version>
</dependency>The NineOldAndroids API is designed to be a drop-in replacement for the Honeycomb (Android 3.0) animation API. To use it, simply change your existing Android animation imports to use the com.nineoldandroids.XXX package instead of android.view.animation.XXX.
Note: LayoutTransition is present in the library, but it cannot be fully implemented on versions prior to Android 3.0.
You can customize the timing and behavior of the property animation using the following methods:
setDuration(long duration): Sets the length of the animation in milliseconds. Throws IllegalArgumentException if duration is negative.getDuration(): Returns the current duration in milliseconds.setStartDelay(long startDelay): Sets the delay before the animation begins in milliseconds. Throws IllegalArgumentException if delay is negative.getStartDelay(): Returns the current start delay in milliseconds.setInterpolator(Interpolator interpolator): Sets the interpolator for the animation.setListener(Animator.AnimatorListener listener): Sets a listener to receive lifecycle events (start, end, cancel, repeat).Use these methods to manually control the execution of the animation:
start(): Explicitly starts the underlying animation.cancel(): Cancels all currently running animations associated with this animator and clears pending animations.The following methods are available to specify which properties of the View should be animated. Each method returns the ViewPropertyAnimator instance to allow for method chaining.
These methods animate a property to a specific target value:
alpha(float value)rotation(float value)rotationX(float value)rotationY(float value)scaleX(float value)scaleY(float value)translationX(float value)translationY(float value)x(float value)y(float value)These methods animate a property by a relative offset from its current value:
alphaBy(float value)rotationBy(float value)rotationXBy(float value)rotationYBy(float value)scaleXBy(float value)scaleYBy(float value)translationXBy(float value)translationYBy(float value)xBy(float value)yBy(float value)getValue(float fraction). The fraction represents the elapsed time of the animation (typically between 0.0f and 1.0f). The method handles cases where the fraction falls outside the [0, 1] range by clamping to the first or last keyframe interval.KeyframeSet.ofObject(...) or a generic KeyframeSet created via ofKeyframe(...) with non-primitive types, you must provide a TypeEvaluator to define how to interpolate between values. Use setEvaluator(TypeEvaluator evaluator) to assign it. Specialized IntKeyframeSet and FloatKeyframeSet do not require this as they use optimized internal evaluators.The KeyframeSet class is used by ValueAnimator to calculate interpolated values between keyframes. While the class itself is marked as an implementation detail, you can use its static factory methods to create specialized sets for different data types:
ofInt(int... values): Creates an IntKeyframeSet where values are distributed evenly across the animation timeline.ofFloat(float... values): Creates a FloatKeyframeSet where values are distributed evenly across the animation timeline.ofObject(Object... values): Creates a KeyframeSet for arbitrary objects, distributing values evenly.ofKeyframe(Keyframe... keyframes): Creates a set from an existing array of Keyframe objects. It automatically selects the most efficient specialized set (Float or Int) if all provided keyframes are of the same primitive type.The ViewPropertyAnimatorHC class provides a Honeycomb-style API for animating multiple properties of an Android View simultaneously. It allows for chaining property animations (like alpha, scale, rotation, and translation) and configuring the animation's duration, start delay, and interpolator.
Note: While the class itself is package-private, it is designed to be accessed via View.animate() in a compatible environment. The available property methods include both absolute value setters (e.g., alpha(float)) and relative offset setters (e.g., alphaBy(float)).