Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Last active June 20, 2018 14:34
Show Gist options
  • Select an option

  • Save EmmanuelGuther/9aebe5751ad5b41f12c45fb8b4995724 to your computer and use it in GitHub Desktop.

Select an option

Save EmmanuelGuther/9aebe5751ad5b41f12c45fb8b4995724 to your computer and use it in GitHub Desktop.
Kotlin function extension to change color animatedly
fun View.changeColorAnimatedly(duration: Long, repeatable: Boolean, startColor: Int, endColor: Int) {
val anim = ObjectAnimator.ofInt(this, "backgroundColor", startColor, endColor)
anim.duration = duration
anim.setEvaluator(ArgbEvaluator())
if (repeatable) {
anim.repeatCount = ValueAnimator.INFINITE
anim.repeatMode = ValueAnimator.REVERSE
}
anim.start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment