java - Android 动画中断问题
问题描述
在一项活动中,我遇到了以下场景的旋转动画问题。我对我的活动布局有两种看法。
- 图像视图
- 文本视图
我为以下操作创建了两个倒数计时器:
- CountDownTimer1:每 1 秒使用txtvw.setText方法将 Textview 文本更新为当前秒。
- CountDownTimer2:每 60 秒执行一次 Image RotateAnimation。
如果我禁用CountDowntimer1 的 setText 方法,CountDowntimer2 的 Rotate 动画运行流畅。但是当我启用CountDowntimer1 的 setText 方法时,旋转动画开始卡顿/中断
我在这里做错了什么?有任何想法吗?谢谢。
解决方案
看看你的 logcat,你可能会得到卡顿/中断动画的原因。你可能会得到类似的声明
I/Choreographer: Skipped 37 frames! The application may be doing too much work on its main thread.
这一定是卡顿/中断动画的原因,您如何解决它是确保您没有阻塞主线程。
你也可以试试<application android:hardwareAccelerated="true" ...>
。但主要问题在于主线程阻塞。
推荐阅读
- sql - 在签出另一项之前签出一项的客户的 SQL 查询
- angular - 如何在 Angular 的应用程序级别设置自动完成“关闭”?
- android - 如何让 Android 10+ 用户从我的应用程序的下载文件夹中导入 zip 文件?
- javascript - Bootstrap V5 & jQuery:再次打开模态框时关闭事件不返回
- r - 是否可以拆分相关框以显示pairplot中两种不同处理的相关值?
- c++ - 在初始化数组中插入字符
- elasticsearch - 弹性转换错误 (Elasticsearch 7.13.3)
- exchangewebservices - Exchange EWS Web 应用程序的问题
- vba - 如何使我的 VBA 用户窗体“半模态”?
- ssl - 仅在端口 443 (HTTPS) 上应答