【问题标题】:How do I add a bounce animation with easing?如何添加带有缓动的反弹动画?
【发布时间】:2019-08-02 05:04:21
【问题描述】:

我想添加一个线性布局的动画,使其垂直向上,然后缓动到它的原始位置。比如this。但是,我只知道如何在没有缓动的情况下让线性布局上升。

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="800"
        android:fromYDelta="50%p"
        />
</set>

这是我添加的垂直向上的动画xml文件。

【问题讨论】:

  • 如果您知道如何使用外部库,请查看Yoyo

标签: java android


【解决方案1】:

你应该使用overshoot_interpolator

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/overshoot_interpolator">
    <translate
            android:duration="800"
            android:fromYDelta="50%p"
    />
</set>

如果您想要更多的自定义,您可以按顺序运行多个翻译动画。您可以使用android:startOffset 来延迟动画并“按顺序”运行它们。 (Example)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    相关资源
    最近更新 更多