且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的缩放动画的弹跳插

更新时间:2022-10-15 08:53:18

终于得到了解决。这对我的作品,可能是帮助他人。关键是把机器人:插标记在动画集

 < XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:插=@机器人:动画/ bounce_interpolator>

<规模
    机器人:时间=600
    机器人:fromXScale =1
    机器人:fromYScale =0.5
    机器人:pivotX =50%
    机器人:pivotY =0%
    机器人:toXScale =1.0
    机器人:toYScale =1.0/>

<阿尔法
    机器人:时间=600
    机器人:fromAlpha =0.0
    机器人:toAlpha =1.0/>

< /集>
 

I am doing a scale animation with anim xml as follows. The animation interpolator isn't working. I am trying to have bounce interpolator but isn't working.

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >

    <scale
        android:duration="900"
        android:fromXScale="1"
        android:fromYScale="0.5"
        android:interpolator="@android:anim/bounce_interpolator"
        android:pivotX="50%"
        android:pivotY="0%"
        android:toXScale="1.0"
        android:toYScale="1.0" />
     </set>

EDIT: Actually my whole xml is

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<scale
    android:duration="600"
    android:fromXScale="1"
    android:fromYScale="0.5"
    android:interpolator="@android:anim/bounce_interpolator"
    android:pivotX="50%"
    android:pivotY="0%"
    android:toXScale="1.0"
    android:toYScale="1.0" />

<alpha
    android:duration="@android:integer/config_longAnimTime"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toAlpha="1.0" />

</set>

Finally got the solution. It works for me and could be helpful to others. The key was to put the android:interpolator tag in the animation 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>