Convert Figma logo to code with AI

florent37 logoViewAnimator

A fluent Android animation library

2,711
424
2,711
26

Top Related Projects

Render After Effects animations natively on Android and iOS, Web, and React Native

Cute view animation collection.

An Android Animation library which easily add itemanimator to RecyclerView items.

Android Transition animations explanation with examples.

5,436

A Java library that models spring dynamics and adds real world physics to your app.

4,381

An Android text view with scrolling text change animation

Quick Overview

ViewAnimator is an Android library that simplifies the process of creating complex animations for views. It provides a fluent API for chaining multiple animations together, making it easy to create smooth and visually appealing transitions and effects for Android UI elements.

Pros

  • Easy-to-use fluent API for creating complex animations
  • Supports a wide range of animation types and properties
  • Lightweight and efficient, with minimal impact on app performance
  • Compatible with most Android versions and view types

Cons

  • Limited documentation and examples for advanced use cases
  • May require additional customization for highly specific animation needs
  • Not actively maintained, with the last update being several years ago
  • Lacks some modern Android animation features introduced in recent versions

Code Examples

  1. Simple fade and translation animation:
ViewAnimator
    .animate(targetView)
        .alpha(0f, 1f)
        .translationY(100f, 0f)
        .duration(1000)
    .start()
  1. Chaining multiple animations:
ViewAnimator
    .animate(view1).scale(0f, 1f)
    .andAnimate(view2).fadeIn()
    .andAnimate(view3).translationX(-100f, 0f)
    .duration(1500)
    .startDelay(250)
    .start()
  1. Using custom interpolators and repeat:
ViewAnimator
    .animate(imageView)
        .rotation(0f, 360f)
        .repeatCount(5)
        .interpolator(OvershootInterpolator())
    .start()

Getting Started

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.florent37:viewanimator:1.1.2'
}
  1. In your Android project, import the library and use it to animate views:
import com.github.florent37.viewanimator.ViewAnimator

// In your activity or fragment
ViewAnimator
    .animate(myView)
        .scale(0f, 1f)
        .duration(1000)
    .start()

Competitor Comparisons

Render After Effects animations natively on Android and iOS, Web, and React Native

Pros of Lottie

  • Supports complex, high-quality animations created in Adobe After Effects
  • Large ecosystem with extensive documentation and community support
  • Cross-platform compatibility (Android, iOS, Web)

Cons of Lottie

  • Steeper learning curve, especially for designers unfamiliar with After Effects
  • Larger file size for complex animations
  • Potential performance issues with very complex animations on low-end devices

Code Comparison

ViewAnimator:

ViewAnimator
    .animate(view)
        .scale(0, 1)
        .duration(1000)
    .start()

Lottie:

val animationView = findViewById<LottieAnimationView>(R.id.animation_view)
animationView.setAnimation(R.raw.animation)
animationView.playAnimation()

Key Differences

  • ViewAnimator focuses on simple, code-based animations for Android views
  • Lottie enables complex, design-driven animations across multiple platforms
  • ViewAnimator offers more granular control over individual view properties
  • Lottie provides a more designer-friendly workflow with After Effects integration

Use Cases

ViewAnimator:

  • Quick, simple animations for Android UI elements
  • Developers who prefer code-based animation control

Lottie:

  • Complex, high-fidelity animations across multiple platforms
  • Projects with dedicated design teams using Adobe tools

Cute view animation collection.

Pros of AndroidViewAnimations

  • More comprehensive set of pre-defined animations
  • Supports chaining multiple animations together
  • Includes a demo app for easy visualization of animations

Cons of AndroidViewAnimations

  • Less flexible for creating custom animations
  • Slightly more verbose syntax for simple animations
  • Not actively maintained (last update in 2017)

Code Comparison

ViewAnimator:

ViewAnimator
    .animate(view)
    .scale(0f, 1f)
    .duration(1000)
    .start()

AndroidViewAnimations:

YoYo.with(Techniques.FadeIn)
    .duration(1000)
    .playOn(view);

ViewAnimator offers a more concise and fluent API for simple animations, while AndroidViewAnimations provides a wide range of pre-defined animations through its Techniques enum. ViewAnimator allows for more customization in a single chain, whereas AndroidViewAnimations may require multiple calls for complex animations.

Both libraries simplify the process of adding animations to Android views, but ViewAnimator is more actively maintained and provides a more modern, Kotlin-friendly approach. AndroidViewAnimations, despite being older, still offers a rich set of ready-to-use animations that can be quickly implemented in projects.

An Android Animation library which easily add itemanimator to RecyclerView items.

Pros of recyclerview-animators

  • Specifically designed for RecyclerView animations, offering a wide range of pre-built animation options
  • Provides fine-grained control over item animations, including custom animation creation
  • Actively maintained with regular updates and a large community of users

Cons of recyclerview-animators

  • Limited to RecyclerView animations, not applicable to other view types
  • Requires more setup and configuration compared to ViewAnimator's simpler API
  • May have a steeper learning curve for developers new to RecyclerView animations

Code Comparison

ViewAnimator:

ViewAnimator
    .animate(view)
    .scale(0, 1)
    .duration(1000)
    .start()

recyclerview-animators:

val animator = SlideInLeftAnimator()
animator.addDuration = 1000
recyclerView.itemAnimator = animator

Summary

ViewAnimator offers a more general-purpose animation solution for various Android views, with a simple and intuitive API. It's suitable for quick implementations and basic animations across different view types.

recyclerview-animators, on the other hand, specializes in RecyclerView animations, providing extensive options and customization for item animations. It's ideal for projects requiring complex RecyclerView animations but may be overkill for simpler use cases.

Choose ViewAnimator for ease of use and versatility across view types, or recyclerview-animators for advanced RecyclerView animation capabilities.

Android Transition animations explanation with examples.

Pros of Material-Animations

  • Focuses on Material Design transitions and animations
  • Provides detailed examples of complex transitions between activities and fragments
  • Includes comprehensive documentation and explanations of Material Design concepts

Cons of Material-Animations

  • Less flexible for general-purpose view animations
  • Requires more setup and code for simple animations
  • Last updated in 2017, potentially outdated for newer Android versions

Code Comparison

Material-Animations:

ActivityOptionsCompat options = ActivityOptionsCompat.
    makeSceneTransitionAnimation(this, fab, fab.getTransitionName());
startActivity(intent, options.toBundle());

ViewAnimator:

ViewAnimator
    .animate(view)
    .scale(0, 1)
    .duration(1000)
    .start();

Key Differences

  • ViewAnimator offers a more concise and chainable API for simple view animations
  • Material-Animations focuses on system-level transitions and Material Design principles
  • ViewAnimator is more actively maintained and updated for recent Android versions
  • Material-Animations provides more comprehensive examples and explanations of complex transitions

Use Cases

  • Choose Material-Animations for implementing Material Design transitions between activities and fragments
  • Opt for ViewAnimator for quick and easy view animations within a single screen or component

Community and Support

  • ViewAnimator has more recent updates and active community support
  • Material-Animations, while older, still offers valuable insights into Material Design concepts
5,436

A Java library that models spring dynamics and adds real world physics to your app.

Pros of Rebound

  • More flexible and powerful spring dynamics system
  • Can be used for a wider range of animation scenarios beyond just view animations
  • Provides a physics-based animation engine for more natural-feeling animations

Cons of Rebound

  • Steeper learning curve due to its more complex API
  • Requires more code to set up basic animations compared to ViewAnimator
  • Less focused on view-specific animations, which may require additional work for simple UI tasks

Code Comparison

ViewAnimator:

ViewAnimator
    .animate(view)
    .scale(0, 1)
    .duration(1000)
    .start()

Rebound:

Spring spring = springSystem.createSpring();
spring.addListener(new SimpleSpringListener() {
    @Override
    public void onSpringUpdate(Spring spring) {
        view.setScaleX((float) spring.getCurrentValue());
        view.setScaleY((float) spring.getCurrentValue());
    }
});
spring.setEndValue(1);

ViewAnimator offers a more concise and readable API for simple view animations, while Rebound provides more control over the animation physics at the cost of verbosity. ViewAnimator is better suited for quick, straightforward UI animations, whereas Rebound excels in creating complex, physics-based animations that can be applied to various scenarios beyond just view manipulation.

4,381

An Android text view with scrolling text change animation

Pros of Ticker

  • Specialized for number/text animations with a scrolling effect
  • Highly customizable with various animation styles and attributes
  • Optimized for performance, especially for frequent updates

Cons of Ticker

  • Limited to text-based animations, less versatile for general view animations
  • Requires more setup for complex animations compared to ViewAnimator
  • Steeper learning curve for advanced customizations

Code Comparison

ViewAnimator:

ViewAnimator
    .animate(view1, view2, view3)
    .scale(0f, 1f)
    .duration(1000)
    .start()

Ticker:

tickerView.setCharacterLists(TickerUtils.provideNumberList())
tickerView.setText("54321", true)

Key Differences

  • ViewAnimator focuses on general view animations, while Ticker specializes in text animations
  • ViewAnimator offers a more fluent API for chaining multiple animations
  • Ticker provides more fine-grained control over text-based animations
  • ViewAnimator is better suited for one-time animations, while Ticker excels at frequent updates

Use Cases

ViewAnimator:

  • General UI animations (fade, scale, translate)
  • Complex view transitions
  • Animating multiple views simultaneously

Ticker:

  • Updating numerical values (e.g., stock prices, countdowns)
  • Animating text changes with a scrolling effect
  • Displaying frequently changing textual data

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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.