【问题标题】:android view animation zoom in and out with bounceandroid视图动画放大和缩小弹跳
【发布时间】:2015-04-14 09:09:18
【问题描述】:

我有一个圆形图像按钮,我想按以下方式制作动画, 将按钮快速缩放到其大小的 1.5 倍,然后以有弹性的效果将其缩小。

为此,我尝试创建一个包含 2 个比例动画的动画集,然后使用 Animation anim = AnimationUtils.loadAnimation(context, R.anim.button); view.startAnimation(anim); 调用它 但即使我在集合中设置了repeatDuration="infinte",它也只会播放一次。

如何在一个视图上无限连续播放多个动画?任何帮助表示赞赏。

button.xml 动画是,

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:ordering="sequentially"
    android:repeatDuration="infinite"
    android:shareInterpolator="false">

    <scale
        android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="1.0"
        android:toXScale="1.1"
        android:fromYScale="1.0"
        android:toYScale="1.0"
        android:duration="2000"
        android:pivotX="50%"
        android:pivotY="50%" />

    <scale
        android:interpolator="@android:anim/bounce_interpolator"
        android:fromXScale="1.1"
        android:fromYScale="1.1"
        android:toXScale="1.0"
        android:toYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="2000"
        android:startOffset="2000" />

</set>

【问题讨论】:

    标签: android animation android-animation android-xml bounce


    【解决方案1】:

    试试这个,把 android:interpolator 放到 set 标签里。

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/bounce_interpolator" >
        <scale
            android:duration="600"
            android:fromXScale="1"
            android:fromYScale="0.5"
            android:pivotX="50%"
            android:pivotY="0%"
            android:toXScale="1.0"
            android:toYScale="1.0" />
    
        <alpha
            android:duration="600"
            android:fromAlpha="0.0"
            android:toAlpha="1.0" />
    </set>
    

    【讨论】:

    • 这对循环播放动画有何帮助?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多