Question

what are kinds of animation techniques in android?

can u tell me the example codes, tutorials for that?

Note: tween and frame animation in the documentation is not enough.....

Was it helpful?

Solution

Basically, besides the (fairly painful) frame/tween animations there are layout animations, view animations and transition animations. Layout animations fire when an element is shown, either at initial activity layout or when you set a view to visible, and transition animations when a new activity is starting. Standard view animations are the workhorse flexible animations you can fire on a per view/layout basis, but they take a bit more work (outside the XML definitions, Activity and Layout animations are generally one-liners).

There are also helpful classes like ViewFlipper to ease working with some of the animations. Check the Android API Demos application that comes with the SDK (documentation here). Easy view animations are in this class, transitions in this class, and some more complex examples here (there's a layout animation example in the 2.0 API demo app, but I can't find it in the online docs). Be sure to check out the related XML for the demos in res/anim, too; the spec on animation XML in the documentation is a bit sparse, but there are plenty of good examples in the API demos and Android source code. You can use XML to customize both the type of transitions (fade, scroll, etc.) and the interpolations (accelerate, overshoot, etc.), which gives a fair amount of power (enough to cover most use cases, anyways).

The AnimationUtils class can help a lot, too. A quick grep through the Android system source code should give you some great working material for all the above. These resources should be enough to get you started; good luck!

ADDENDUM (5/2011): There's also the (3.0+ only) property animation system, which is really cool because you can use it to animate arbitrary properties on custom views; unless you're writing a 3.0-specific app, you'll need to wait before using it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top