title: Why android may do performMeasure() twice in ViewRootImpl?
body: <p>Why android may do <code>performMeasure()</code> twice in <code>ViewRootImpl</code>?<br>
  After first <code>performMeasure()</code>, Android will check if the <code>lp.horizontalWeight</code> or the <code>lp.verticalWeight</code> was set, then it may do the second time <code>performMeasure()</code>.</p>
  
  <p>Here is my question why Android doesn't check before the first time, then just do <code>performMeasure()</code> once?</p>
  
  <pre><code>               // Ask host how big it wants to be
                  performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
  
                  // Implementation of weights from WindowManager.LayoutParams
                  // We just grow the dimensions as needed and re-measure if
                  // needs be
                  int width = host.getMeasuredWidth();
                  int height = host.getMeasuredHeight();
                  boolean measureAgain = false;
  
                  if (lp.horizontalWeight &gt; 0.0f) {
                      width += (int) ((mWidth - width) * lp.horizontalWeight);
                      childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width,
                              MeasureSpec.EXACTLY);
                      measureAgain = true;
                  }
                  if (lp.verticalWeight &gt; 0.0f) {
                      height += (int) ((mHeight - height) * lp.verticalWeight);
                      childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height,
                              MeasureSpec.EXACTLY);
                      measureAgain = true;
                  }
  
                  if (measureAgain) {
                      if (DEBUG_LAYOUT) Log.v(TAG,
                              "And hey let's measure once more: width=" + width
                              + " height=" + height);
                      performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
                  }
  </code></pre>