Deep Understanding of Physics-based Animations In Android

Taku Semba
Sep 16, 2017 · 2 min read

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

Moving View

Rotating

Rotating View

Scaling

Scaling View

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!

Taku Semba

Written by

Android Engineer at AbemaTV Github: https://github.com/takusemba

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade