Skip to content

Instantly share code, notes, and snippets.

@ademar111190
Created June 17, 2019 17:13
Show Gist options
  • Select an option

  • Save ademar111190/b3823f13c732a8a05c7b2a9fdf260f4e to your computer and use it in GitHub Desktop.

Select an option

Save ademar111190/b3823f13c732a8a05c7b2a9fdf260f4e to your computer and use it in GitHub Desktop.
Step 9, the animation manager
...
import android.animation.AnimatorSet
import android.animation.ObjectAnimator.ofInt
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
...
private var animator: AnimatorSet? = null
...
private fun startUpdateRectAnimation(rect: Rect) {
animator?.cancel()
animator = AnimatorSet().also {
it.playTogether(
ofInt(this, "rectLeft", this.rect.left, rect.left),
ofInt(this, "rectRight", this.rect.right, rect.right),
ofInt(this, "rectTop", this.rect.top, rect.top),
ofInt(this, "rectBottom", this.rect.bottom, rect.bottom)
)
it.interpolator = FastOutSlowInInterpolator()
it.duration = resources.getInteger(android.R.integer.config_shortAnimTime).toLong()
it.start()
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment