onCreate
1. ApplicationThread#schedueLaunchActivity
2. ActivityThread#handleLaunchActivity
3. ActivityThread#performLaunchActivity
4. Activity#attach
調(diào)用Activity.setContentView
1. PhoneWindow#installDecor(初始化DecorView及ContentParent)
2. mLayoutInflater.inflate(layoutResID, mContentParent);
#inflate此處
LayoutInflator#rInflate 最終finishInflate=true:觸發(fā)parent.onFinishInflate();
LayoutInflator#createView#constructor.newInstance(args);最終調(diào)用 XXX(Context context, AttrsSet args);
# 至此鸟赫,View對(duì)象們已經(jīng)存在mContentParent的子對(duì)象中.
onResume
- ActivityThread#performResumeActivity
- Activity#performResume
2.1 performResume#performRestart
2.2 觸發(fā)performStart,調(diào)試模式彈窗,-> enterReady
2.2.1 activity.getWindow().getDecorView().setVisibility(View.VISIBLE);
2.2.2 triggerViewsReady#decor.invalidate();
2.2.3 View#invalidateInternal內(nèi)
// Propagate the damage rectangle to the parent view.
final AttachInfo ai = mAttachInfo;
final ViewParent p = mParent;
if (p != null && ai != null && l < r && t < b) {
final Rect damage = ai.mTmpInvalRect;
damage.set(l, t, r, b);
# All or part of a child is dirty and needs to be redrawn.
p.invalidateChild(this, damage);
}
ViewRootImpl#scheduleTraversals#最終會(huì)重繪界面 onMeasure/onLayout/onDraw
2.3 onResume
DecorView extends FrameLayout
- 根布局
- mContentParent
ViewRootImpl
- 實(shí)現(xiàn)View和WindowManager之間的協(xié)議缀壤。具體詳看WindowManagerGlobal
WindowManagerGlobal
- 維護(hù)View ViewRootImpl LayoutParams的順序存儲(chǔ)筋夏。
updateViewLayout和removeView都是在ViewRootImpl的基礎(chǔ)上進(jìn)行操作的
view.invalidate最終也是調(diào)用到ViewRootImpl#scheduleTraversals,其performMeasure/Layout/Draw
ViewRootImpl的內(nèi)部緩存View對(duì)象
WindowManager的實(shí)現(xiàn)類WindowManagerImpl的內(nèi)部調(diào)用WindowManagerGlobal的具體實(shí)現(xiàn)。