Last active
August 29, 2017 12:51
-
-
Save pablisco/d79d07daa882c27b8ce819f3a5337690 to your computer and use it in GitHub Desktop.
Medium: Smooth loading
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="loading_animation_start">#9b9b9b</color> | |
<color name="loading_animation_end">#d2d2d2</color> | |
</resources> |
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 ImageView.startLoadingAnimation( | |
@ColorRes startColorRes: Int, | |
@ColorRes endColorRes: Int | |
) { | |
animate( | |
ArgbEvaluator(), | |
colors[startColorRes], | |
colors[endColorRes], | |
onConfig = { | |
duration = 1000 | |
repeatMode = ValueAnimator.REVERSE | |
repeatCount = ValueAnimator.INFINITE | |
}, | |
onUpdate = this::setBackgroundColor | |
).start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment