Created
March 28, 2019 12:56
-
-
Save riggaroo/24d0ef28579644c4b127d771b069c241 to your computer and use it in GitHub Desktop.
Example showing how to use PropertyValuesHolder to animate a custom views properties.
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
private fun animateToPoint(point: Point) { | |
val propertyX = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_X, dropperPoint.x, point.x) | |
val propertyY = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_Y, dropperPoint.y, point.y) | |
val animator = ValueAnimator() | |
animator.setValues(propertyX, propertyY) | |
animator.interpolator = OvershootInterpolator() | |
animator.duration = 100 | |
animator.addUpdateListener { animation -> | |
val animatedX = animation.getAnimatedValue(ColorDropperView.PROPERTY_X) as Float | |
val animatedY = animation.getAnimatedValue(ColorDropperView.PROPERTY_Y) as Float | |
setPoint(Point(animatedX, animatedY)) | |
} | |
animator.start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment