Generally speaking, an animtion is a dynamic medium in which images or objects are manipulated to appear as moving images.
That is if Wikipedia is to be believed. Webopedia on the other hand defines an animation as a simulation of movement created by displaying a series of pictures, or frames.
It is not the art of making drawings move, but the art of drawing movement, according to Science World British Columbia.
Android provides us a wealth of APIs we can use for animating various View objects.So whenever the user interface changes in response to user action, we should strive to animate the layout transitions. Animations are important as they provide users with feedback on their actions. This helps keep them oriented to the UI.
To easily animate changes between two view hierarchies, we can use the Android Transitions Framework. This framework animates us the views at runtime. It does this by changing some of the property values of those views over time. We get built-in animations for common effects. Furthermore through this Framework we can create custom animations and transition lifecycle callbacks.
We can visual cues via animations. These then can notify users about what's going on in our app. Especially when the User Interface changes state, such as when new content loads or new actions become available.
Android provides us with various animation APIs.
Android provides drawable animation APIs. These APIs are in most cases defined statically with a drawable resource. However we can also define them at runtime. These animation APIs allow us animate bitmaps.
Find more details here.
Alot of times you need to manipulate the visibility or position of views within a layout. In that case you should include subtle animations to help the user understand how the UI is changing.
For instance you can:
views.For that you can use the property animation system provided by the
android.animation package. This package is available in
Android 3.0 (API level 11) and higher.
These APIs work by updating the properties of our View objects over a period of time. Thus the views are continuously redrawn as the properties change.
Find more documentation here.
You can create animations by applying real-world physics.This makes those animations natural-looking. For example, they should maintain momentum when their target changes, and make smooth transitions during any changes.
Android Support Library gives us the APIs for creating these animations. Those APIs do actually apply the laws of physics to control how your animations occur.
The Transition Framework allows us to create animations when we swap the layout within the current activity of fragment. However this is only applicable in
Android 4.4(API Level 19) and above.
To do this you specify the starting and ending layout, and what type of animation you want to use. The system will then figure out and executes an animation between the two layouts. You can use this to swap out the entire UI or to move/replace just some views.
You can also create animations that transition between activities. This is only applicable to
Android 5.0 (API level 21) and higher. Again this is based on the same transition framework described above to animate layout changes. However in this case it allows us to create animations between layouts in separate activities.
We can apply simple animations such as sliding the new activity in from the side or fading it in. We can also create animations that transition between shared views in each activity.
startActivity(), but pass it a bundle of options provided by
ActivityOptions.makeSceneTransitionAnimation(). This bundle of options may include which views are shared between the activities so the transition framework can connect them during the animation.
Let's look at some examples.
ObjectAnimator is a class that allows properties on target objects. This class derives from