# ViewAnimator
**Repository Path**: li_yu_jiang/ViewAnimator
## Basic Information
- **Project Name**: ViewAnimator
- **Description**: A fluent Android animation library。安卓动画库,加入了一些不错的动画,如:wave、fall、shake、flash、fadeIn、rollOut……支持任意路径动画(示例动画为不断冒出来的桃心及飘雪),支持按SVG格式的path运动。已合并到原作者florent37的主分支
- **Primary Language**: Android
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: https://github.com/florent37/ViewAnimator.git
- **GVP Project**: No
## Statistics
- **Stars**: 67
- **Forks**: 22
- **Created**: 2016-01-26
- **Last Updated**: 2025-02-13
## Categories & Tags
**Categories**: android-modules, animation
**Tags**: None
## README
ViewAnimator
=======
[](https://github.com/florent37/ViewAnimator/tree/master)
[](http://android-arsenal.com/details/1/2942)
A fluent Android animation library !
[](https://github.com/florent37/ViewAnimator)
# Usage
Animate multiple view from one method
```java
ViewAnimator
.animate(image)
.translationY(-1000, 0)
.alpha(0,1)
.andAnimate(text)
.dp().translationX(-20, 0)
.decelerate()
.duration(2000)
.thenAnimate(image)
.scale(1f, 0.5f, 1f)
.accelerate()
.duration(1000)
.start();
```
[](https://youtu.be/ZHw8MfOM1Eg)
Without ViewAnimator
```java
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(image,"translationY",-1000,0),
ObjectAnimator.ofFloat(image,"alpha",0,1),
ObjectAnimator.ofFloat(text,"translationX",-200,0)
);
animatorSet.setInterpolator(new DescelerateInterpolator());
animatorSet.setDuration(2000);
animatorSet.addListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation) {
AnimatorSet animatorSet2 = new AnimatorSet();
animatorSet2.playTogether(
ObjectAnimator.ofFloat(image,"scaleX", 1f, 0.5f, 1f),
ObjectAnimator.ofFloat(image,"scaleY", 1f, 0.5f, 1f)
);
animatorSet2.setInterpolator(new AccelerateInterpolator());
animatorSet2.setDuration(1000);
animatorSet2.start();
}
});
animatorSet.start();
```
# More
[](https://youtu.be/Qlj40Y6ChSM)
Add same animation on multiples view
```java
ViewAnimator
.animate(image,text)
.scale(0,1)
.start();
```
Add listeners
```java
ViewAnimator
.animate(image)
.scale(0,1)
.onStart(() -> {})
.onStop(() -> {})
.start();
```
Use DP values
```java
ViewAnimator
.animate(image)
.dp().translationY(-200, 0)
.start();
```
Animate Height / Width
```java
ViewAnimator
.animate(view)
.waitForHeight() //wait until a ViewTreeObserver notification
.dp().width(100,200)
.dp().height(50,100)
.start();
```
Color animations
```java
ViewAnimator
.animate(view)
.textColor(Color.BLACK,Color.GREEN)
.backgroundColor(Color.WHITE,Color.BLACK)
.start();
```
Rotation animations
```java
ViewAnimator
.animate(view)
.rotation(360)
.start();
```
Custom animations
```java
ViewAnimator
.animate(text)
.custom(new AnimationListener.Update() {
@Override public void update(TextView view, float value) {
view.setText(String.format("%.02f",value));
}
}, 0, 1)
.start();
```
Cancel animations
```java
ViewAnimator viewAnimator = ViewAnimator
.animate(view)
.rotation(360)
.start();
viewAnimator.cancel();
```
Enhanced animations (Thanks [AndroidViewAnimations](https://github.com/daimajia/AndroidViewAnimations) and [NiftyDialogEffects](https://github.com/sd6352051/NiftyDialogEffects) )
```java
.shake().interpolator(new LinearInterpolator());
.bounceIn().interpolator(new BounceInterpolator());
.flash().repeatCount(4);
.flipHorizontal();
.wave().duration(5000);
.tada();
.pulse();
.standUp();
.swing();
.wobble();
```
...

Path animations ( Inspiration from http://blog.csdn.net/tianjian4592/article/details/47067161 )
```java
final int[] START_POINT = new int[]{ 300, 270 };
final int[] BOTTOM_POINT = new int[]{ 300, 400 };
final int[] LEFT_CONTROL_POINT = new int[]{ 450, 200 };
final int[] RIGHT_CONTROL_POINT = new int[]{ 150, 200 };
Path path = new Path();
path.moveTo(START_POINT[0], START_POINT[1]);
path.quadTo(RIGHT_CONTROL_POINT[0], RIGHT_CONTROL_POINT[1], BOTTOM_POINT[0], BOTTOM_POINT[1]);
path.quadTo(LEFT_CONTROL_POINT[0], LEFT_CONTROL_POINT[1], START_POINT[0], START_POINT[1]);
path.close();
ViewAnimator.animate(view).path(path).repeatCount(-1).start();
```
# Download
Add into your **build.gradle**
[](https://bintray.com/florent37/maven/ViewAnimator/_latestVersion)
```groovy
compile 'com.github.florent37:viewanimator:1.1.0'
```
# Community
Looking for contributors, feel free to fork !
# Credits
Author: Florent Champigny
Contributor: [李玉江(liyujiang)](https://github.com/gzu-liyujiang/ViewAnimator)
Fiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)
# License
Copyright 2015 florent37, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.