最近遇到這個問題,一個activity中有一個imageview的旋轉動畫,當activity剛打開時,前幾秒這個旋轉的動畫沒有轉動的過程,過了0.幾秒以后直接卡到某個未知接著轉.到處搜索都是說activity出現時的過渡動畫的問題,感覺人類語言不足以精簡的表達這種事情ORZ.
Google后找到了這個文章 和 這個文章,大致就是說:
It’s important to note that the start() method called on the AnimationDrawable cannot be called during the onCreate() method of your Activity, because the AnimationDrawable is not yet fully attached to the window.
大致就是說將startAnimation放到onWindowFocusChanged中就好了,然后試了試因為視覺差還是感覺卡頓,于是直接將動畫delay了,確實有效.
新聞熱點
疑難解答