問題:
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. 編輯:讓我清楚一點 - 我的問題是,爲什麼在帖子上啓動動畫會導致它啓動,當在主線程上啓動動畫時沒有。