Android 动画中的Interpolator

简介: package android.animation;/** * 时间插值器定义了一个动画的变化率。 * 这让动画让非线性的移动轨迹,例如加速和减速。 * <hr/> * A time interpolator defines the rate of change of an animation. This allows animations * to



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



目录
相关文章
|
8月前
|
Android开发
Android RecyclerView的notify方法和动画的刷新详解(二)
Android RecyclerView的notify方法和动画的刷新详解
137 0
|
7月前
|
Android开发
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等(三)
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等
|
7月前
|
Android开发
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等(一)
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等
|
7月前
|
Android开发
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等(二)
Android RecyclerView 使用大全 - 基础使用,item 动画,下拉刷新等
|
3月前
|
XML 开发工具 Android开发
Android动画效果-更新中
Android动画效果-更新中
59 1
|
4月前
|
XML Android开发 数据格式
[Android]动画
[Android]动画
31 0
|
4月前
|
API Android开发 开发者
【Android App】Vulkan实现宇宙中旋转雷达动画效果(附源码和原始视频 超详细必看)
【Android App】Vulkan实现宇宙中旋转雷达动画效果(附源码和原始视频 超详细必看)
68 1
|
4月前
|
XML 小程序 Java
【Android App】给三维魔方贴图以及旋转动画讲解和实战(附源码和演示视频 超详细必看)
【Android App】给三维魔方贴图以及旋转动画讲解和实战(附源码和演示视频 超详细必看)
27 0
|
4月前
|
XML Java Android开发
Android App开发手机阅读中实现平滑翻书效果和卷曲翻书动画实战(附源码 简单易懂 可直接使用)
Android App开发手机阅读中实现平滑翻书效果和卷曲翻书动画实战(附源码 简单易懂 可直接使用)
66 0
|
4月前
|
XML Java Android开发
Android App开发手机阅读中贝塞尔曲线的原理讲解及实现波浪起伏动画实战(附源码和演示视频 可直接使用)
Android App开发手机阅读中贝塞尔曲线的原理讲解及实现波浪起伏动画实战(附源码和演示视频 可直接使用)
44 0