Skip to content

Builders for state animations

Compare
Choose a tag to compare
@davidganster davidganster released this 06 Sep 20:47
· 3 commits to master since this release

This release adds a few simpler builder methods to the AnimationState<V> class, and a few specializations for Android Views, such as the ViewAnimationState.

The improvements to the AnimationState API were made to provide a simpler, safer alternative to the usage of addEndAction(), since there are always potential race conditions when executing end actions in highly interactive animations.

The new API allows you to create states on the fly without too much syntactic overhead:

AdditiveAnimator.animate(target)
    .state(new ViewAnimationState(
        new ViewAnimation(View.TRANSLATION_X, 40f),
        new ViewAnimation(View.TRANSLATION_Y, 40f),
    ))
    .start()

You can now also more easily create custom visibility animations (with custom start/end actions) by utilizing the new ViewVisibilityBuilder.