package android.animation;
/**
* 时间插值器定义了一个动画的变化率。
* 这让动画让非线性的移动轨迹,例如加速和减速。
* <hr/>
* A time interpolator defines the rate of change of an animation. This allows animations
* to have non-linear motion, such as acceleration and deceleration.
*/
public interface TimeInterpolator {
/**
* 将动画已经消耗的时间的分数映射到一个表示插值的分数。
* 然后将插值与动画的变化值相乘来推导出当前已经过去的动画时间的动画变化量。
* <hr/>
* Maps a value representing the elapsed fraction of an animation to a value that represents
* the interpolated fraction. This interpolated value is then multiplied by the change in
* value of an animation to derive the animated value at the current elapsed animation time.
*
* @param input 一个0到1.0表示动画当前点的值,0表示开头。1表示结尾<br/> A value between 0 and 1.0 indicating our current point
* in the animation where 0 represents the start and 1.0 represents
* the end
* @return 插值。它的值可以大于1来超出目标值,也小于0来空破底线。<br/>The interpolation value. This value can be more than 1.0 for
* interpolators which overshoot their targets, or less than 0 for
* interpolators that undershoot their targets.
*/
float getInterpolation(float input);
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:shareInterpolator="false" >
<!--
android:interpolator="@android:anim/decelerate_interpolator"是什么含义,
文档里说的也不太清楚,其实很简单,看下面:
interpolator定义一个动画的变化率(the rate of change)。
这使得基本的动画效果(alpha, scale, translate, rotate)得以加速,减速,重复等。
-->
<!--
accelerate_decelerate_interpolator 在动画开始与介绍的地方速率改变比较慢,在中间的时侯加速
accelerate_interpolator 在动画开始的地方速率改变比较慢,然后开始加速
decelerate_interpolator 在动画开始的地方速率改变比较慢,然后开始减速
cycle_interpolator 动画循环播放特定的次数,速率改变沿着正弦曲线
linear_interpolator 在动画的以均匀的速率改变(变化率是个常数,即 f (x) = x.)
overshoot_interpolator 向前甩一定值后再回到原来位置
bounce_interpolator 动画结束的时候弹起
-->
<rotate
android:duration="3000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+1080" />
<translate
android:duration="300"
android:fromXDelta="0"
android:fromYDelta="0"
android:interpolator="@android:anim/bounce_interpolator"
android:startOffset="2500"
android:toXDelta="200"
android:toYDelta="200" />
<alpha
android:duration="100"
android:fromAlpha="1.1"
android:interpolator="@android:anim/accelerate_interpolator"
android:startOffset="2700"
android:toAlpha="0.0" />
</set><!--
如果在一个set标签中包含多个动画效果,如果想让这些动画效果共享一个Interpolator。
android:shareInterpolator = "true"
如果不想共享一个interpolator,则设置android:shareInterpolator="false",并且需要在每一个动画效果处添加interpolator。
-->
2016年6月4日18:24:00 16568