View繪制的三部曲, 測(cè)量,布局,繪畫(huà)
今天我們分析測(cè)量過(guò)程
view的測(cè)量是從ViewRootImpl發(fā)起的,View需要重繪,都是發(fā)送請(qǐng)求給ViewRootImpl,然后他組織重繪
在重繪的過(guò)程中,有一步就是測(cè)量,通過(guò)代碼來(lái)分析測(cè)量過(guò)程
private boolean measureHierarchy(final View host, final WindowManager.LayoutParams lp, final Resources res, final int desiredWindowWidth, final int desiredWindowHeight) { int childWidthMeasureSpec; int childHeightMeasureSpec; boolean windowSizeMayChange = false; if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v(TAG, "Measuring " + host + " in display " + desiredWindowWidth + "x" + desiredWindowHeight + "..."); boolean goodMeasure = false; if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT) { // On large screens, we don't want to allow dialogs to just &n