Skip to content

Instantly share code, notes, and snippets.

@pablisco
Last active August 29, 2017 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablisco/d79d07daa882c27b8ce819f3a5337690 to your computer and use it in GitHub Desktop.
Save pablisco/d79d07daa882c27b8ce819f3a5337690 to your computer and use it in GitHub Desktop.
Medium: Smooth loading
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="loading_animation_start">#9b9b9b</color>
<color name="loading_animation_end">#d2d2d2</color>
</resources>
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