Reputation: 193
I've been looking around the web and also on the developer guide for Android but couldn't find any SIMPLE way to animate my views sequentially as I want. I'd like to be able to execute several animations like this
yourView.animate().xBy(100).setDuration(500);
yourView.animate().alpha(0).setDuration(500);
yourView.animate().whateverIwannaDo(...).setDuration(...);
...
with (or without) a waiting time between each animation and without having to use AnimatorSet or AnimationSet (which I don't understand even after reading the developer guide) :/
If there is no way to do so then would there be any clear guide which would explain step by step how to use AnimatorSet and all that.
I hope you guys will be indulgent in relation to my problem.
Thanks in advance.
Upvotes: 0
Views: 72
Reputation: 8293
I encourage you to use NineOldAndroid. It’s a library that allow to use Honeycomb animation API for all versions of the Android platform.
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(myView, "rotationX", 0, 360),
ObjectAnimator.ofFloat(myView, "translationX", 0, 90),
ObjectAnimator.ofFloat(myView, "scaleX", 1, 1.5f),
ObjectAnimator.ofFloat(myView, "alpha", 1, 0.25f, 1));
set.setDuration(5 * 1000).start();
To use this library you have three options:
With gradle
, in your build.gradle configuration file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
}
}
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
}
Using maven
:
<dependency>
<groupId>com.nineoldandroids</groupId>
<artifactId>library</artifactId>
<version>2.4.0</version>
</dependency>
Also, you can add it to your project as a dependency jar
Upvotes: 1