上一篇文章主要介绍了Activity的结构
这一篇开始介绍view的绘制流程
一、绘制入口
- ActivityThread.handleResumeActivity–>
- WindowManagerImpl.addView(dercorView,LayoutParams)–>
- WindowManagerGlobal.addView()
绘制的类及方法
- ViewRootImpl.setView(decorView,layoutParams,parentView)–>
- ViewRootImpl.requestLayout()–>scheduleTraversals()–>doTraversal()–>performTraversals()
绘制三大步骤
- 测量:ViewRootImpl.performMeasure
- 布局:ViewRootImpl.performLayout
- 绘制:ViewRootImpl.performDraw
测量:ViewRootImpl.performMeasure
view.measure–>view.onMeasure–>view.setMeasuredDimension–>setMeasuredDimensionRaw
布局:ViewRootImpl.performLayout
view.layout–>view.onLayout
绘制:ViewRootImpl.performDraw
ViewRootImpl.draw(fullRedrawNeeded)–>ViewRootImpl.drawSoftware–>view.draw(Canvas)