Created
January 28, 2020 09:36
-
-
Save Farbklex/a4a05a7764387ef965749936211d0b1a to your computer and use it in GitHub Desktop.
Simple "flashing" animation for an android view
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
package me.a_hoffmann.gists | |
import android.animation.ValueAnimator | |
import android.view.View | |
object FlashingAnimator { | |
const val ANIMATION_DURATION: Long = 800 | |
/** | |
* Executes a "flashing" animation on a view | |
*/ | |
fun playHighlightAnimation(view: View) { | |
val animator = ValueAnimator.ofFloat(0.1f, 1f) | |
animator.addUpdateListener { valueAnimator -> | |
view.alpha = valueAnimator.animatedValue as Float | |
view.requestLayout() | |
} | |
animator.duration = ANIMATION_DURATION | |
animator.start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment