Created
November 22, 2018 20:13
-
-
Save bitvale/22ca2a61668e801a31fec4310ea09978 to your computer and use it in GitHub Desktop.
For Medium article "Android Dynamic Custom View is Easy"
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
// ... | |
var amplitude = BOUNCE_ANIM_AMPLITUDE_IN | |
var frequency = BOUNCE_ANIM_FREQUENCY_IN | |
var newProgress = 1f | |
if (!checked) { | |
amplitude = BOUNCE_ANIM_AMPLITUDE_OUT | |
frequency = BOUNCE_ANIM_FREQUENCY_OUT | |
newProgress = 0f | |
} | |
val switcherAnimator = ValueAnimator.ofFloat(iconProgress, newProgress).apply { | |
addUpdateListener { | |
iconProgress = it.animatedValue as Float | |
} | |
interpolator = BounceInterpolator(amplitude, frequency) | |
duration = SWITCHER_ANIMATION_DURATION | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment