2014-09-29 2 views
0

제 1의 레이아웃을 확대하고 싶습니다 .2 번째로 바운스를 축소해야합니다. 그러나이 코드는 올바르게 작동하지 않습니다.두 개의 눈금이있는 Android 바운스 애니메이션

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:ordering="sequentially" > 
<set> 
    <scale 
     android:duration="400" 
     android:fromXScale="1.0" 
     android:fromYScale="1.0" 
     android:pivotX="50%" 
     android:pivotY="50%" 
     android:toXScale="1.2" 
     android:toYScale="1.2" /> 
</set> 

<set android:interpolator="@android:anim/bounce_interpolator" > 
    <scale 
     android:duration="800" 
     android:fromXScale="1.2" 
     android:fromYScale="1.2" 
     android:pivotX="50%" 
     android:pivotY="50%" 
     android:toXScale="1.0" 
     android:toYScale="1.0" /> 
</set></set> 

답변

3

개체 애니메이터에 대해 많이 알지는 않지만 속성 애니메이션을 여러 번 사용하여 크기 조정을했는데 잘되었습니다. 무슨 배 규모에 대한 코드

AnimatorSet set = new AnimatorSet(); //this is your animation set. 
    //add as many Value animator to it as you like 

    ValueAnimator scaleUp = ValueAnimator.ofFloat(1,(float)1.2); 
    scaleUp.setDuration(800); 
    scaleUp.setInterpolator(new BounceInterpolator()); //remove this if you prefer default interpolator 
    scaleUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 
     @Override 
     public void onAnimationUpdate(ValueAnimator valueAnimator) { 
      Float newValue = (Float) valueAnimator.getAnimatedValue(); 
      yourView.setScaleY(newValue); 
      yourView.setScaleX(newValue); 
     } 
    }); 

    ValueAnimator scaleDown = ValueAnimator.ofFloat((float)1.2,1); 
    scaleDown.setDuration(800); 
    scaleDown.setInterpolator(new BounceInterpolator()); 
    scaleDown.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 
     @Override 
     public void onAnimationUpdate(ValueAnimator valueAnimator) { 
      Float newValue = (Float) valueAnimator.getAnimatedValue(); 
      yourView.setScaleY(newValue); 
      yourView.setScaleX(newValue); 
     } 
    }); 


    set.play(saceleUp); 
    set.play(scaleDown).after(scaleUP); 
    set.start(); 
+0

입니까?) –

+0

확인 업데이트 대답 – Reza

+0

너무 많은 코드, 추측)이 작업은 애니메이션 XML에 의해 –

관련 문제