2015-04-14 1 views
2

J'ai un bouton d'image circulaire que je voudrais animer de la manière suivante, agrandir le bouton à 1,5 fois sa taille rapidement, puis faites un zoom arrière avec un effet plein d'entrain.android voir l'animation zoom avant et arrière avec le rebond

Pour cela, je suis en train de créer un ensemble d'animation avec 2 animations à l'échelle en elle et l'appeler avec Animation anim = AnimationUtils.loadAnimation(context, R.anim.button); view.startAnimation(anim); mais il joue qu'une seule fois même si je mets le repeatDuration="infinte" dans l'ensemble.

Comment puis-je lire plusieurs animations sur une vue en séquence de façon infinie? Toute aide appréciée.

Le anim button.xml est,

<?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> 

Répondre

1

essayer ceci, mettre android: interpolateur dans la balise 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> 
+0

Comment cela aide-t-il à jouer les animations dans une boucle? – Bootstrapper