android activity剛打開時內部動畫卡頓問題

最近遇到這個問題,一個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了,確實有效.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章