2014-06-09 2 views
0

내 애플리케이션에서 애니메이션을하고 있습니다. 하나의 작은 세부 사항을 제외하고는 잘 작동합니다. 애니메이션이 완료 될 때까지 UI가 응답하지 않습니다. 나는 스크롤 할 수없고, 다른 것을하지 않는다.Android ObjectAnimator가 UI를 고정시킵니다.

나는 이것을 Runnable에 두는 것이 해결책이 아니라는 것을 읽었다. 그래서 나는 잃어 버렸어.

궁극적으로 저는 각 객체가 객체의 크기에 따라 다른 기간을 사용하여 애니메이션이 더 작은 원에서 더 빠르게 실행되고 더 큰 원에서 느리게 실행되도록하고 싶습니다. 여기

내가 내 애니메이션을 테스트해야하는 코드입니다 :

HoleView holeView = (HoleView) view.findViewById(R.id.holeView1); 
    ObjectAnimator oa1 = ObjectAnimator.ofInt(holeView, "animationTime", 0, holeView.getAnimationTime()); 
    oa1.setDuration(holeView.getAnimationTime()); 

    holeView = (HoleView) view.findViewById(R.id.holeView2); 
    ObjectAnimator oa2 = ObjectAnimator.ofInt(holeView, "animationTime", 0, holeView.getAnimationTime()); 
    oa2.setDuration(holeView.getAnimationTime()); 

    holeView = (HoleView) view.findViewById(R.id.holeView3); 
    ObjectAnimator oa3 = ObjectAnimator.ofInt(holeView, "animationTime", 0, holeView.getAnimationTime()); 
    oa3.setDuration(holeView.getAnimationTime()); 

    holeView = (HoleView) view.findViewById(R.id.holeView4); 
    ObjectAnimator oa4 = ObjectAnimator.ofInt(holeView, "animationTime", 0, holeView.getAnimationTime()); 
    oa4.setDuration(holeView.getAnimationTime()); 

    AnimatorSet animatorSet = new AnimatorSet(); 
    animatorSet.play(oa1).with(oa2).with(oa3).with(oa4); 
    animatorSet.start(); 

답변

0

대신 값 애니메이터를 사용해보십시오 : 어디 그런

public static ValueAnimator animate(float from, float to, long duration) { 
     ValueAnimator anim = ValueAnimator.ofFloat(from, to); 
     anim.setDuration(duration); 
     return anim; 
    } 

:

가 ValueAnimator를 반환하는 방법을 만들기 예를 들어 imageView라고하는 ImageView의 축척을 설정하려는 경우 다음을 수행하십시오.

//where 0 is the start value, 1 is the end value, and 850 is the duration in milliseconds 
ValueAnimator imageAnimator = animate(0, 1, 850); 

imageAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 
     @Override 
     public void onAnimationUpdate(ValueAnimator anim) { 
      float scale = (Float) anim.getAnimatedValue(); 
      imageView.setScaleX(scale); 
      imageView.setScaleY(scale); 
     } 
    }); 

imageAnimator.start(); 
관련 문제