Skip to content

Instantly share code, notes, and snippets.

@bitvale
Created November 22, 2018 20:13
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 bitvale/22ca2a61668e801a31fec4310ea09978 to your computer and use it in GitHub Desktop.
Save bitvale/22ca2a61668e801a31fec4310ea09978 to your computer and use it in GitHub Desktop.
For Medium article "Android Dynamic Custom View is Easy"
// ...
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