首页 > 解决方案 > Android 动画中断问题

问题描述

在一项活动中,我遇到了以下场景的旋转动画问题。我对我的活动布局有两种看法。

  1. 图像视图
  2. 文本视图

我为以下操作创建了两个倒数计时器:

  1. CountDownTimer1:每 1 秒使用txtvw.setText方法将 Textview 文本更新为当前秒。
  2. CountDownTimer2:每 60 秒执行一次 Image RotateAnimation。

如果我禁用CountDowntimer1 的 setText 方法,CountDowntimer2 的 Rotate 动画运行流畅。但是当我启用CountDowntimer1 的 setText 方法时,旋转动画开始卡顿/中断

我在这里做错了什么?有任何想法吗?谢谢。

标签: javaandroidanimationcountdowntimer

解决方案


看看你的 logcat,你可能会得到卡顿/中断动画的原因。你可能会得到类似的声明

I/Choreographer: Skipped 37 frames!  The application may be doing too much work on its main thread.

这一定是卡顿/中断动画的原因,您如何解决它是确保您没有阻塞主线程。

你也可以试试<application android:hardwareAccelerated="true" ...>。但主要问题在于主线程阻塞。


推荐阅读