简体   繁体   English

Android Animation 中断问题

[英]Android Animation Disruption Issue

In a activity I have been having Rotate animation issue for the following scenario.在一项活动中,我一直在针对以下场景遇到 Rotate animation 问题。 I have two views on my activity layout.我对我的活动布局有两种看法。

  1. ImageView ImageView
  2. TextView TextView

I have created two Countdown-timers for the following operations:我为以下操作创建了两个倒数计时器:

  1. CountDownTimer1: Every 1 second update the Textview text with current second using method txtvw.setText method. CountDownTimer1:每 1 秒使用txtvw.setText方法将 Textview 文本更新为当前秒数。
  2. CountDownTimer2: After every 60 seconds perform Image RotateAnimation. CountDownTimer2:每 60 秒执行一次图像旋转动画。

The Rotate animation of CountDowntimer2 runs smoothly if I disable the setText method of CountDowntimer1.如果禁用CountDowntimer1的setText方法,CountDowntimer2的Rotate animation运行很流畅。 But rotate animation starts to stutter/disrupt when I enable the setText method of CountDowntimer1但是当我启用CountDowntimer1 的 setText 方法时,旋转 animation 开始断断续续/中断

What wrong am I doing here?我在这里做错了什么? Any ideas?有任何想法吗? Thanks.谢谢。

Look at your logcat you might get the reason for the stutter/disrupt animation. You might be getting statement like查看您的 logcat,您可能会得到口吃/中断 animation 的原因。您可能会得到类似的声明

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

This must be the reason for the stutter/disrupt animation, how you can fix it is to make sure you are not blocking the main thread.这一定是口吃/中断 animation 的原因,您如何修复它是为了确保您没有阻塞主线程。

You can try <application android:hardwareAccelerated="true"...> as well.您也可以尝试<application android:hardwareAccelerated="true"...> But the main issue is in the main thread getting block.但主要问题是主线程被阻塞了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM