Created
May 4, 2019 14:07
-
-
Save bitvale/753dcfaf985e07615c60ca4ad65d9d82 to your computer and use it in GitHub Desktop.
For Medium article "Animate Everything! (Android Animation Showcase)"
This file contains hidden or 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
override fun onDraw(canvas: Canvas) { | |
canvas?.drawOval(defRect, backgroundPaint) | |
canvas?.drawOval(animatedRect, foregroundPaint) | |
} | |
fun startAnimation() { | |
// ... | |
val animateLeft = ObjectAnimator.ofFloat(animatedRect, "left", animatedRect.left, toRect.left) | |
val animateTop = ObjectAnimator.ofFloat(animatedRect, "top", animatedRect.top, toRect.top) | |
val animateRight = ObjectAnimator.ofFloat(animatedRect, "right", animatedRect.right, toRect.right) | |
val animateBottom = ObjectAnimator.ofFloat(animatedRect, "bottom", animatedRect.bottom, toRect.bottom) | |
val foregroundColorAnimator = ValueAnimator().apply { /* init animator */ } | |
val backgroundColorAnimator = ValueAnimator().apply { /* init animator */ } | |
animatorSet.apply { | |
// init animator set | |
playTogether(animateLeft, animateTop, animateRight, animateBottom, foregroundColorAnimator, backgroundColorAnimator) | |
duration = ANIMATION_DURATION | |
start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment