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



目录
相关文章
|
2月前
|
存储 Shell Android开发
基于Android P,自定义Android开机动画的方法
本文详细介绍了基于Android P系统自定义开机动画的步骤,包括动画文件结构、脚本编写、ZIP打包方法以及如何将自定义动画集成到AOSP源码中。
58 2
基于Android P,自定义Android开机动画的方法
|
5月前
|
Java Android开发 开发者
Android10 修改开发者选项中动画缩放默认值
Android10 修改开发者选项中动画缩放默认值
158 0
|
5月前
|
XML Java Android开发
android的三种动画
android的三种动画
37 0
|
3月前
|
XML Android开发 数据格式
Android 中如何设置activity的启动动画,让它像dialog一样从底部往上出来
在 Android 中实现 Activity 的对话框式过渡动画:从底部滑入与从顶部滑出。需定义两个 XML 动画文件 `activity_slide_in.xml` 和 `activity_slide_out.xml`,分别控制 Activity 的进入与退出动画。使用 `overridePendingTransition` 方法在启动 (`startActivity`) 或结束 (`finish`) Activity 时应用这些动画。为了使前 Activity 保持静止,可定义 `no_animation.xml` 并在启动新 Activity 时仅设置新 Activity 的进入动画。
72 12
|
3月前
|
XML Android开发 UED
Android动画之共享元素动画简单实践
本文介绍Android共享元素动画, 实现两Activity间平滑过渡特定UI元素。通过设置`transitionName`属性和使用`ActivityOptions.makeSceneTransitionAnimation`启动目标Activity实现动画效果。可自定义过渡动画提升体验。
51 0
|
4月前
|
Android开发 UED
Android Item平移动画
【6月更文挑战第18天】
|
3月前
|
Android开发
android 动画 插值器和估值器
android 动画 插值器和估值器
|
5月前
|
数据库 Android开发
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画
|
5月前
|
Java Android开发
Android开发之使用OpenGL实现翻书动画
本文讲述了如何使用OpenGL实现更平滑、逼真的电子书翻页动画,以解决传统贝塞尔曲线方法存在的卡顿和阴影问题。作者分享了一个改造后的外国代码示例,提供了从前往后和从后往前的翻页效果动图。文章附带了`GlTurnActivity`的Java代码片段,展示如何加载和显示书籍图片。完整工程代码可在作者的GitHub找到:https://github.com/aqi00/note/tree/master/ExmOpenGL。
127 1
Android开发之使用OpenGL实现翻书动画