【问题标题】:how to edit an android animation interpolator?如何编辑android动画插值器?
【发布时间】:2013-07-31 10:58:15
【问题描述】:

我需要制作一个比例驱动的动画对话框。我想使用反弹插值器尝试过的反弹效果

<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromXScale="0"
    android:fromYScale="0"
    android:interpolator="@android:anim/bounce_interpolator"
    android:toXScale="1"
    android:toYScale="1" />

我想修改反弹效果,使其更慢/更快,以及反弹的大小。我什么都没找到, T试图用套装来制作它

<set >
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="500"
        android:fromXScale="0"
        android:fromYScale="0"
        android:toXScale="1"
        android:toYScale="1" />
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="100"
        android:fromXScale="1"
        android:fromYScale="1"
        android:startOffset="500"
        android:toXScale=".8"
        android:toYScale=".8" />
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="100"
        android:fromXScale=".8"
        android:fromYScale=".8"
        android:startOffset="600"
        android:toXScale="1"
        android:toYScale="1" />
</set>

整个动画表现的很奇怪? 所以我的问题是如何通过设置修复这个动画或者如何修改bounce_interpolator?

【问题讨论】:

    标签: android animation scale interpolation bounce


    【解决方案1】:

    使用 ipfx.org 创建自定义插值器。
    以退回示例为例并根据您的需要进行编辑。
    http://ipfx.org/?p=7ffffffe575efffe9e02fffed8f6fffe&l=2f13c5ac138b3d6ad338a5a77a8386807d6e

    比在你的应用程序中使用创建的插值器()

    import org.ipfx.Interpolator;
    
    ...
    ...
    
    final org.ipfx.Interpolator interpolator = org.ipfx.Interpolator.parseUrl(urlData);
    
    ObjectAnimator animator = ObjectAnimator.ofFloat(...);
    animator.setDuration(1000);
    
    animator.setInterpolator(new TimeInterpolator() {
        @Override
        public float getInterpolation(float input) {
            return interpolator.calc(input);
        }
    });
    
    animator.start();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      • 2023-02-07
      • 1970-01-01
      相关资源
      最近更新 更多