Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example showing how to use PropertyValuesHolder to animate a custom views properties.
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