Deep Understanding of Physics-based Animations In Android
As of support library 26, Physics-based animations got available in Android, Spring Animation and Fling Animation. Both helps you implement Spring or Fling Animation of views without any complicated code.
How To Start
dependencies {
...
compile "com.android.support:support-dynamic-animation:26.1.0"
}
Spring Animation
Spring Animation has some attributes like stiffness or dumping ratio which determines how view springs.
You can make views moving, rotating, scaling with Spring Animation :)
Moving
Rotating
Scaling
Fling Animation
Fling Animation comes in handy when you want to fling views, and it’s really easy to use.
Set the first velocity and friction. That it.
val flingAnimation = FlingAnimation(yourView, DynamicAnimation.X)
.setFriction(3f)
.setStartVelocity(10f)
flingAnimation.start()
Last
Recently, I created a library “CropMe” using Physics-based Animations.
It helps you crop image, is extremely smooth and easy. Please check this out and give me a STAR if you like it!