
我想创建一个自定义插值来应用平移动画,其中动画应该通过以下函数:
public static float easeIn(float t,float b , float c, float d) { return c*(t/=d)*t + b; }其中:
t: current timeb: start valuec: change in valued: duration 我找到了一个实现缩放动画,如果只采用一个参数:
import androID.vIEw.animation.Interpolator;public class MyInterpolator implements Interpolator { public MyInterpolator() { } public float getInterpolation(float t) { float x = 2.0f * t - 1.0f; return 0.5f * (x * x * x + 1.0f); }}如何使用上面的函数创建插值来进行翻译.
解决方法:
简答:从名称我想你的easyIn应该是AccelerateInterpolator
您编写的函数不是插补器可以执行的 *** 作.插值器不关心它是Scale-,Alpha-还是TranslateAnimation.
文档解释了Interpolator getInterpolation如下:
介于0和1.0之间的值表示动画中的当前点,其中0表示开始,1.0表示结束
内插器提供从经过的时间(相对)映射到动画进度的功能.您可以想象它以%为单位,getInterpolation(xy)会告诉您
“如果通过总持续时间的xy%,应该传递多少%的动画?”
以linearInterpolator为例.实现将如下所示:
public float getInterpolation(float t) { return t}示例:使用linearInterpolator从0px动画到200px:
45%(0.45)的时间后,45%(返回0.45)的动画应该通过,即90px(200px * 0.45)
请阅读此内容以获取详细信息:
Android Animations Tutorial 5: More on Interpolators
总结以上是内存溢出为你收集整理的如何创建自定义插值器以在android中应用翻译动画全部内容,希望文章能够帮你解决如何创建自定义插值器以在android中应用翻译动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)