A fluent Android animation library

Overview

ViewAnimator

API Android Arsenal

A fluent Android animation library !

Android app on Google Play

png

Usage

Animate multiple view from one method

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();
       

gif

Without ViewAnimator

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

gif

Add same animation on multiples view

ViewAnimator
       .animate(image,text)
       .scale(0,1)
       .start();

Add listeners

ViewAnimator
       .animate(image)
       .scale(0,1)
       .onStart(() -> {})
       .onStop(() -> {})
       .start();

Use DP values

ViewAnimator
       .animate(image)
       .dp().translationY(-200, 0)
       .start();

Animate Height / Width

ViewAnimator
       .animate(view)
       .waitForHeight() //wait until a ViewTreeObserver notification
       .dp().width(100,200)
       .dp().height(50,100)
       .start();

Color animations

ViewAnimator
       .animate(view)
       .textColor(Color.BLACK,Color.GREEN)
       .backgroundColor(Color.WHITE,Color.BLACK)
       .start();

Rotation animations

ViewAnimator
       .animate(view)
       .rotation(360)
       .start();

Custom animations

ViewAnimator
       .animate(text)
       .custom(new AnimationListener.Update<TextView>() {
            @Override public void update(TextView view, float value) {
                  view.setText(String.format("%.02f",value));
            }
        }, 0, 1)
       .start();

Cancel animations

ViewAnimator viewAnimator = ViewAnimator
       .animate(view)
       .rotation(360)
       .start();

viewAnimator.cancel();

Enhanced animations (Thanks AndroidViewAnimations and NiftyDialogEffects )

.shake().interpolator(new LinearInterpolator());
.bounceIn().interpolator(new BounceInterpolator());
.flash().repeatCount(4);
.flipHorizontal();
.wave().duration(5000);
.tada();
.pulse();
.standUp();
.swing();
.wobble();

... Preview

Path animations ( Inspiration from http://blog.csdn.net/tianjian4592/article/details/47067161 )

    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

Buy Me a Coffee at ko-fi.com

Add into your build.gradle

Download

compile 'com.github.florent37:viewanimator:1.1.0'

Community

Looking for contributors, feel free to fork !

Credits

Author: Florent Champigny
Contributor: 李玉江(liyujiang)

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

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.
Comments
  • i got a memory leak with Animator$AnimatorListener

    i got a memory leak with Animator$AnimatorListener

    • android.arch.lifecycle.ReportFragment has leaked:
    • static Choreographer.!(mMainInstance)!
    • ↳ Choreographer.!(mCallbackQueues)!
    • ↳ array Choreographer$CallbackQueue[].!([1])!
    • ↳ Choreographer$CallbackQueue.!(mHead)!
    • ↳ Choreographer$CallbackRecord.!(action)!
    • ↳ AnimationHandler$1.!(this$0)! (anonymous implementation of android.view.Choreographer$FrameCallback)
    • ↳ AnimationHandler.!(mAnimationCallbacks)!
    • ↳ ArrayList.!(elementData)!
    • ↳ array Object[].!([2])!
    • ↳ AnimatorSet.!(mListeners)!
    • ↳ ArrayList.!(elementData)!
    • ↳ array Object[].!([0])!
    • ↳ ViewAnimator$1.!(this$0)! (anonymous implementation of android.animation.Animator$AnimatorListener)
    • ↳ ViewAnimator.!(animationList)!
    • ↳ ArrayList.!(elementData)!
    • ↳ array Object[].!([0])!
    • ↳ AnimationBuilder.!(views)!
    • ↳ array View[].!([0])!
    • ↳ AppCompatImageView.mContext
    • ↳ PerformanceAty.mFragments
    • ↳ FragmentController.mHost
    • ↳ Activity$HostCallbacks.mFragmentManager
    • ↳ FragmentManagerImpl.mAdded
    • ↳ ArrayList.elementData
    • ↳ array Object[].[0]
    • ↳ ReportFragment

    my code is :

    public static void viewScaleButtonAnimation(View... view) {
        ViewAnimator.animate(view).scale(1, 1.05f, 1).duration(3000)
                .repeatCount(-1).start();
    }
    

    how can i release this anim??

    opened by LiveSalton 5
  • repeatMode(ValueAnimator.INFINITE) doesn't work

    repeatMode(ValueAnimator.INFINITE) doesn't work

    Hello,

    Here is my code:

    ViewAnimator viewAnimator = ViewAnimator.animate(textView)
                    .tada()
                    .duration(4000)
                    .repeatMode(ValueAnimator.INFINITE)
                    .start();
    

    The animation works but the 'ValueAnimator.INFINITE' value (which is an enum that is equal to "-1") doesn't work to make the animation loop indefinitely.

    Could someone help me to find the issue?

    opened by NayMak 5
  • consider migrating to maven or jitpack

    consider migrating to maven or jitpack

    @florent37 jCenter is currently deprecated and artifacts can only be downloaded till 2022-02-01, consider migrating to jitpack or maven central. more info here

    opened by yamin8000 3
  • Library is broken from 1.0.1 to 1.0.2

    Library is broken from 1.0.1 to 1.0.2

    animation = ViewAnimator .animate(logo).scaleX(0, 1).scaleY(0, 1).alpha(0, 1).descelerate().duration(500) .thenAnimate(logo).scaleX(1, 0).scaleY(1, 0).alpha(1, 0).accelerate().duration(500);

    descelerate cannot exists...

    opened by FireZenk 3
  • add path animation, add repeat count and repeat mode...

    add path animation, add repeat count and repeat mode...

    add some enhanced animations, such as slideLeft,slit,fall,.. add path animation, use path of android and svg; add repeat count and repeat mode; update screenshots;

    添加一些增强的动画,如从左边滑出、狭缝、大转盘…… 添加路径动画,支持Android的Path类及SVG的path标签; 增加重复次数和重复模式; 更新效果图及README.md;

    opened by liyujiang-gzu 1
  • 加入动画的view无法控制显示和隐藏

    加入动画的view无法控制显示和隐藏

    loadingCycleIvAnim = ViewAnimator .animate(loadingCycleIv) .rotation(360) .repeatCount(-1) .start(); loadingCycleIvAnim.cancel(); loadingCycleIv.setVisibility无法控制了

    opened by xmutzlq 0
  • your app in google play

    your app in google play

    java.lang.NoSuchFieldError: No field zzcsl of type Ljava/lang/Object; in class Lcom/google/android/gms/internal/adn; or its superclasses (declaration of 'com.google.android.gms.internal.adn' appears in /data/app/com.florent37.github.florent.champigny-1/base.apk) at com.google.android.gms.internal.zzay.zzo(Unknown Source) at com.google.android.gms.internal.zzax.(Unknown Source) at com.google.android.gms.internal.zzcar.zzvy(Unknown Source) at com.google.android.gms.internal.zzcar.onConnectionFailed(Unknown Source) at com.google.android.gms.common.internal.zzn.zzj(Unknown Source) at com.google.android.gms.common.internal.zze.zzs(Unknown Source) at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source) at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.os.HandlerThread.run(HandlerThread.java:61)

    opened by qiushui95 0
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • add Animator singleInterpolator

    add Animator singleInterpolator

    Very nice project! I really love it.It helps me reduce a lot of code in my project.

    So, I achieved some new feature that for every single animator set it's Interpolator. I hope you like it.

    Forgive my poor English,Have a good time! ^_^

    opened by Skykai521 0
  • move enhanced animations to sample2,add some animations ;....

    move enhanced animations to sample2,add some animations ;....

    add sample2, add follower animation, add multi heart animation; move enhanced animations to sample2; remove automatically generated javadoc; compress gif, update screenshot and README.md;

    opened by liyujiang-gzu 0
Releases(1.0.4)
Owner
Florent CHAMPIGNY
Florent CHAMPIGNY
[] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!

DEPRECATED NineOldAndroids is deprecated. No new development will be taking place. Existing versions will (of course) continue to function. New applic

Jake Wharton 4.5k Jan 9, 2023
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Adrián Lomas 1.2k Nov 18, 2022
FPSAnimator is very easy animation library for Android TextureView and SurfaceView.

FPSAnimator A simple but powerful Tween / SpriteSheet / ParabolicMotion / animation library for Android TextureView and SurfaceView. Features The cont

Masayuki Suda 756 Dec 30, 2022
Android library to make notes drop animation for music players

VusikView Min SDK 11 Screnshots How to use If you want use this library, you can download project and import it into your workspace and add the projec

Chetan Kaushik 119 Nov 29, 2022
An simple & awesome animation library written in Kotlin for Android

An simple & awesome animation library written in Kotlin for Android

Romman Sabbir 53 Oct 17, 2022
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

LottieDialog Android Library to create Lottie animation view dialog easily with a lot of customization Why you should use Lottie Dialog You have no li

Amr Hesham 39 Oct 7, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

Android Library to create Lottie animation view dialog easily with a lot of customization

Amr Hesham 39 Oct 7, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
User onboarding library with smooth animation of objects and background colors

SlidingTutorial Cleveroad introduces Sliding Tutorial Library for Flutter Hey guys, hope you haven’t started developing a tutorial for your Flutter ap

Cleveroad 127 Dec 31, 2022
This library provides easy ways to add onboarding or pager screens with different animation and indicators.

WalkThroughAndroid Make amazing OnBoarding Screens easily for your app with different colorful animations, fonts, styles, and many more. Customize you

MindInventory 33 Sep 9, 2022
A library support circular imageview with rotation animation

Circular Imageview with Rotate Animation This is a fast and efficient open source custom imageview for Android that allow to easy implement disc anima

Nhien Nguyen 5 Jul 24, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Orbitary ?? Jetpack Compose animation library that allows you to implement animations such as shared element transition. Download Gradle Add the depen

Jaewoong Eum 503 Dec 30, 2022
FadingToolbar is an animation library which fades out your footer view in a ScrollView/RecyclerView and fades in a toolbar title

FadingToolbar is an animation library which fades out your footer view in a ScrollView/RecyclerView and fades in a toolbar title (analogue of the LargeTitle animation in iOS)

Hanna 9 Nov 3, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

?? Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Jaewoong Eum 504 Jan 2, 2023
A component for flip animation on Android, which is similar to the effect in Flipboard iPhone/Android

android-flip Aphid FlipView is a UI component to accomplish the flipping animation like Flipboard does. A pre-built demo APK file for Android OS 2.2+

Bo 2.8k Dec 21, 2022
Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

Codesoup 161 Jan 1, 2023
DuGuang 1k Dec 14, 2022