Skip to content

Instantly share code, notes, and snippets.

@bitvale
Created May 5, 2019 20:52
Show Gist options
  • Save bitvale/a006c54d017ae69b3fc204728fc1715f to your computer and use it in GitHub Desktop.
Save bitvale/a006c54d017ae69b3fc204728fc1715f to your computer and use it in GitHub Desktop.
For Medium article "Animate Everything! (Android Animation Showcase)"
fun animateItemsOut() = animate(R.anim.item_animation_out)
fun animateItemsIn() = animate(R.anim.item_animation_in)
private fun animate(@AnimRes animationId: Int) {
var startOffset = 0L
for (i in childCount - 1 downTo 0) {
val set = AnimationUtils.loadAnimation(context, animationId)
set.startOffset = startOffset
getChildAt(i)?.startAnimation(set)
startOffset += ANIMATION_OFFSET
set.withEndActionOnce { updateViews() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment