Created
May 5, 2019 20:52
-
-
Save bitvale/a006c54d017ae69b3fc204728fc1715f to your computer and use it in GitHub Desktop.
For Medium article "Animate Everything! (Android Animation Showcase)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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