The Tween Material Motion family provides a bridge between Property Animation and the Material Motion Runtime.
Tween
uses Property Animation's ObjectAnimator to animate a property along an easing curve.
Use a Tween like you would use a ObjectAnimator instance: provide a property, duration, and one or both of the from/to value.
Tween tweenBackgroundColor = new Tween<>(TweenProperty.BACKGROUND_COLOR, duration, Color.GREEN, Color.RED);
runtime.addPlan(tweenBackgroundColor, view);
Tween's properties map to the following ObjectAnimator properties:
Tween | Property Animation |
---|---|
delay | startDelay |
duration | duration |
from | values... |
property | property |
to | values... |
interpolator | interpolator |
Learn more about the APIs defined in the library by reading our technical documentation and our Starmap.
Add the Jitpack repository to your project's build.gradle
:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Depend on the latest version of the library. Take care to occasionally check for updates.
dependencies {
compile 'com.github.material-motion:family-tween-android:2.1.0'
}
For more information regarding versioning, see:
You can have a copy of this library with local changes and test it in tandem
with its client project. To add a local dependency on this library, add this
library's identifier to your project's local.dependencies
:
com.github.material-motion:family-tween-android
Because
local.dependencies
is never to be checked into Version Control Systems, you must also ensure that any local dependencies are also defined inbuild.gradle
as explained in the previous section.
Important
For each local dependency listed, you must run gradle install
from its
project root every time you make a change to it. That command will publish your
latest changes to the local maven repository. If your local dependencies have
local dependencies of their own, you must gradle install
them as well.
You must gradle clean
your project every time you add or remove a local
dependency.
How to use the library in your project.
Open Android Studio,
choose File > New > Import
,
choose the root build.gradle
file.
To build the sample application, run the following commands:
git clone https://github.com/material-motion/family-tween-android.git
cd family-tween-android
gradle installDebug
To run all unit tests, run the following commands:
git clone https://github.com/material-motion/family-tween-android.git
cd family-tween-android
gradle test
Tween<Float> tween = new Tween<>(property, duration, from, to);
runtime.addPlan(tween, view);
float[] values = new float[] {0f, .5f, 1f};
float[] offsets = new float[] {0f, .25f, 1f};
Tween<Float> tween = new Tween<>(property, duration, values);
tween.offsets = offsets;
runtime.addPlan(tween, view);
We welcome contributions!
Check out our upcoming milestones.
Learn more about our team, our community, and our contributor essentials.
Licensed under the Apache 2.0 license. See LICENSE for details.