Skip to content

Defining Custom Animations

Ivan Škorić edited this page Oct 31, 2017 · 1 revision

In order to define you own custom animations, you can either use AnimationBuilder directly or wrap it in separate methods to create a nice API for more convenient usage. Here's a sample:

// Spins the given view for 360.
public static AnimationCompletable spin360(View view) {
  return AnimationBuilder.forView(view)
      .rotation(360)
      .duration(500L)
      .interpolator(new AccelerateDecelerateInterpolator())
      .buildCompletable();
}

To execute the animation, just subscribe to the AnimationCompletable returned by the spin360() method:

public void animateMyView() {
  spin360(someView).subscribe();
}