Wednesday, January 14, 2009

To accelerate or to decelerate ?

As many developers discovering a new development environment, I use and abuse of copy and paste.
Starting a new feature process is : 
  • finding in the documentation, or on the internet a similar feature, or something as close as possible, 
  • try to find the parameter/line / bit of code to change to have something like what I had in mind in the first time,
  • Be happy :)
  • ( if I have some time : fully understanding what I've just written... )

And most of the time, I don't have that much have time !

For my tries with animations, I find a sample that moved a view, copied this sample for making my high score list view slide out and in. And that's all.

Only now, I discover that in the sample animation I copied, there was this parameter :
android:interpolator="@android:anim/accelerate_interpolator"

And only now, I discover my mistake. The accelerator interpolator makes the speed of the moving view increase with the time.
So when my high score listview is sliding out of the screen, it has a slow speed at first, when one can see it in its integrality, and a fast speed at the end of the animation, when only a little part of it is visible.

But on the contrary, when it is sliding in in the screen, it has its greatest speed at the end of the animation, when one can see it in its integrality !
This just makes a awful animation !

Now that I discovered that my animation can decelerate for slides in, it is way better !


4 comments:

skink said...

if you want to play with interpolators see stuff i made some time ago http://code.google.com/p/android-easing-interpolators

Android Blogger said...

Interesting !
I'm unsure what you use a in/out /inout setting.
Is it a common thing to do ?

Nice job, anyway, and I like very much the idea to plot the animation !

skink said...

many ajax frameworks use easing animations with in/out/inout modifiers

Android Blogger said...

Ahh!!

I don't know at all about Ajax !
So much thing to learn, so little time :)