Androidinterpolatorandroidanimaccelerateinterpolator

android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />

The animation identifies the interpolator it wants to useā€”the accelerate_interpolator, in this case. There is a corresponding Java object that defines this interpolator. Also, note that we've specified this interpolator as a resource reference. This means there must be a file corresponding to the anim/accelerate_interpolator that describes what this Java object looks like and what additional parameters it might take. That indeed is the case. Look at the XML file definition for @android:anim/accelerate_interpolator:

<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android" factor="1" />

You can see this XML file in the following subdirectory within the Android package:

/res/anim/accelerate_interpolator.xml

The accelerateInterpolator XML tag corresponds to a Java object with this name:

android.view.animation.AccelerateInterpolator

You can look up the Java documentation for this class to see what XML tags are available. This interpolator's goal is to provide a multiplication factor given a time interval based on a hyperbolic curve. The source code for the interpolator illustrates this:

public float getInterpolation(float input) {

return (float)(input * input);

return (float)Math.pow(input, 2 * mFactor);

Every interpolator implements this getInterpolation method differently. In this case, if the interpolator is set up so that the factor is 1.0, it will return the square of the factor. Otherwise, it will return a power of the input that is further scaled by the factor. So if the factor is 1.5, then you will see a cubic function instead of a square function. The supported interpolators include

AccelerateDecelerateInterpolator

AccelerateInterpolator

CycleInterpolator

DecelerateInterpolator

LinearInterpolator

You can find the behavior of these interpolators described at the following URL:

http://code.google.com/android/reference/android/view/animation/package-summary.html

The Java documentation for each of these classes also points out the XML tags available to control them.

This concludes our section on layout animation. We will now move to the third section on view animation, in which we'll discuss animating a view programmatically.

0 0

Post a comment