2016-08-17 1 views
1

Android에서 AnimationDrawable을 반전하는 방법.Android에서 AnimationDrawable로 끝나는 애니메이션을 반대로

내 앱을 최적화하려면 애니메이션이 끝날 때 되돌리기를 원합니다. 나는 애니메이션이 5 개 새로운 이미지를로드하는 것이 아니라 방향을 변경하고자하지만 난 그렇게하는 방법을 발견하지

AnimationDrawable animation = new AnimationDrawable(); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball1), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball2), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball3), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball4), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball5), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball6), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball5), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball4), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball3), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball2), 100); 
    animation.addFrame(getResources().getDrawable(R.drawable.ball1), 100); 
    animation.setOneShot(false); 

    ImageView imageAnim = (ImageView) findViewById(R.id.image_view1); 
    imageAnim.setBackgroundDrawable(animation); 

    animation.start(); 

:

여기 내 코드입니다.

감사

티보

답변

-1

이 보간에게

public class ReverseInterpolator implements Interpolator { 
    @Override 
    public float getInterpolation(float paramFloat) { 
    return Math.abs(paramFloat -1f); 
    } 
} 


animation.setInterpolator(new ReverseInterpolator()); 
+0

당신이 유용 – Don

+1

이 방법을 사용할 수 없습니다 대답을 수락 찾을 경우 추가 "setInterpolator()"를 애니메이션 드로어 블 AnimationDrawable에 –

관련 문제