有時我們使用activity轉場動畫的時候,沒有再demo流暢,原因可能是因為動畫進行時,有同時加載數據等進行主線程操作,所以會導致動畫不夠流暢. 解決辦法就是在動畫結束后再進行數據加載等相關操作. activity里有一個方法
/** * Activities cannot draw during the period that their windows are animating in. In order * to know when it is safe to begin drawing they can override this method which will be * called when the entering animation has completed. */ public void onEnterAnimationComplete() { }這個就是在動畫結束后的回調.這樣效果就會好一些.
但是要注意的是該接口API21的,所以之前的舊版本就不能這么用了.
新聞熱點
疑難解答