Item animations

Saket Narayan edited this page Oct 20, 2018 · 3 revisions

Animations

InboxRecyclerView uses a class called ItemExpandAnimator for moving the list items while the content is expanding, collapsing or being pulled.

This library offers two animations out of the box:

1. Split

This is the default animator. It splits the list when the content is expanding. Items above the expanding item are pushed towards the top and the rest towards the bottom.

recyclerView.itemExpandAnimator = ItemExpandAnimator.split()

TODO: Video

2. Scale

I'm yet to add this, but the plan is to mimic the animations used in Reply. If you're interested in adding this, I'd appreciate a PR.

Make your own

Creating custom animations are really easy. ItemExpandAnimator contains just one abstract function that is responsible for animating the items.

recyclerView.itemExpandAnimator = object : ItemExpandAnimator() {

  override fun onPageMove() {
    // This gets called every time the 
    // content changes position on the screen.
  }
}

The existing animators are also open classes so you can simply extend them and customize as needed.

Duration and Interpolator

By default, a duration of 250ms and the FastOutSlowInInterpolator() interpolator are used for item animations. This can be changed using,

expandablePageLayout.animationDurationMillis = CUSTOM_DURATION
expandablePageLayout.animationInterpolator = CUSTOM_INTERPOLATOR
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.