问题:
I've encountered a very weird feature. 我遇到了一个非常奇怪的功能。
When I'm trying to run an animation on the main thread, it does not start. 当我试图在主线程上运行动画时,它不会启动。 When I run said animation using 当我使用运行所述动画
getView().post(new Runnable() {
@Override
public void run() {
getView().startAnimation(a);
}
});
It does start. 它确实开始了。
I've printed the CurrentThread
before starting the animation and both print main
. 我在开始动画之前打印了CurrentThread
并且都打印了main
。
Obviously, I am missing something here, as both should start the animation on the main thread... My guess is that as post adds the task to the queue, it starts at a more "correct time", but I would love to know what happens here at more depth. 显然,我在这里遗漏了一些东西,因为两者都应该在主线程上启动动画......我的猜测是,当post将任务添加到队列中时,它会在更“正确的时间”开始,但我很想知道这里发生的事情更深入。
EDIT: Let me clear things up - my question is, why starting the animation on post causes it to start, when starting the animation on the main thread does not. 编辑:让我清楚一点 - 我的问题是,为什么在帖子上启动动画会导致它启动,当在主线程上启动动画时没有。