0

我的应用具有某些需要呈现复杂布局的操作。在那段时间,我想展示一个动画。我正在尝试处理 dispatchDraw() 中的动画,但由于渲染需要很长时间,所以 UI dispatchDraw() 永远没有机会执行。(优化它会很好,但这不是我现在的首要任务。)

这是我的动画代码的重要部分:

ValueAnimator animator = ValueAnimator.ofFloat (1f, 2f);
animator.setDuration (1000);
animator.addUpdateListener (new ValueAnimator.AnimatorUpdateListener()
{
  public void onAnimationUpdate (ValueAnimator animation)
  {
    zoomScale = (float) animation.getAnimatedValue ();
    invalidate ();
  }
});

有没有办法在onAnimationUpdate()期间直接绘制,而不是依赖invalidate()?

或者,有没有办法在长时间的 onLayout() 期间放弃 UI 线程?

4

0 回答 0