Activity的onContentChange,onAttac

2020-05-31  本文已影响0人  ModestStorm

1.onContentChange:在onCreate中调用setContentView()方法时回调。

Activity.onCreate>Activity.setContentView>getWindow().setContenView
>PhoneWindow.setContentView()>Activity.onContentChanged

2.onAttachedToWindow:在view渲染之前回调,具体的是指ViewRootImpl. performTraversals()方法中调用。

Activity.onCreate->Activity.onStart->Activity.onResume->WindowManager.addView(DecorView,l)->WindowMangerImpl.addView
>WindowMangerGlobal.addView->ViewRootImpl.setView
>ViewRootImpl.requestLayout->ViewRootImpl.performTraversals->DecorView.onAttachedToWindow(依次调用DecorView.onAttachedToWindow,所有子View的onAttachedToWindow,最后调用Activity.onAttachedToWindow,然后开始View树渲染流程的调用)->performMeasure->performLayout->performDraw

3.onWindowFocuseChanged(hasFocus: Boolean):Activity第一帧渲染完成后开始回调,该方法会调用多次,比如在Activity上面显示Dialog,pop等对应着hasFocus值的改变。

DecorView.onMeasure>DecorView.onLayout>DecorView.onDraw>View.onFocuseChanged->ViewGroup.onFocusChanged->Activity.onFocuseChanged
上一篇下一篇

猜你喜欢

热点阅读