Last active
June 20, 2018 14:34
-
-
Save EmmanuelGuther/9aebe5751ad5b41f12c45fb8b4995724 to your computer and use it in GitHub Desktop.
Kotlin function extension to change color animatedly
This file contains hidden or 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 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