美文网首页
Activity的onContentChange,onAttac

Activity的onContentChange,onAttac

作者: ModestStorm | 来源:发表于2020-05-31 22:58 被阅读0次

    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
    

    相关文章

      网友评论

          本文标题:Activity的onContentChange,onAttac

          本文链接:https://www.haomeiwen.com/subject/ugkdzhtx.html