简体   繁体   English

动画多个textviews

[英]animating multiple textviews

whats the best way to accomplish the following, 什么是完成以下任务的最佳方法,

I need to update these textivews from lets say 0 to 1000 simultaneously, but it has to seem like the textview is counting up. 我需要将这些textivews从0改为同时更新为1000,但是看来textview正在增加。 You know like a count down animation. 你知道像倒计时动画。 Except it goes from a specific value to a higher value. 除非它从特定值变为更高的值。 I tried running multiple threads and updating the textviews but I don't think is a good approach, I also used a thread executor. 我尝试运行多个线程并更新textviews,但我认为这不是一个好方法,我还使用了一个线程执行器。

textview 1 - 0 - 100 | textview 1-0-100 | textview 2 - 0 - 300 | textview 2-0-300 | textview 3 - 0 - 600 | textview 3-0-600 | textview 4 - 0 - 100 | textview 4-0-100 |

Have you checked out the Chronometer class? 您是否已完成Chronometer课程? It's a pretty basic class, extending TextView , that uses a simple Handler with sendMessageDelayed to update the value. 这是一个非常基本的类,它扩展了TextView ,它使用带有sendMessageDelayed的简单Handler来更新值。 See the method updateRunning() in the source. 请参阅源代码中的方法updateRunning()

代替线程,您应该尝试Handler,在处理程序的postDelayed方法中,您可以传递可运行的代码以执行代码以更新textview,并再次安排处理程序以进行下一个postDelayed执行。

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

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