protected override void Measure() { base.Measure(); if (null != Skin) { MeasuredWidth = Skin.GetExplicitOrMeasuredWidth(); MeasuredHeight = Skin.GetExplicitOrMeasuredHeight(); MeasuredMinWidth = Skin.ExplicitWidth ?? Skin.MinWidth; MeasuredMinHeight = Skin.ExplicitHeight ?? Skin.MinHeight; } }
protected override void Measure() { //Debug.Log(string.Format("Measure...")); base.Measure(); // A ViewStack measures itself based only on its selectedChild. // The minimum, maximum, and preferred sizes are those of the // selected child, plus the borders and margins. float minWidth = 0; float minHeight = 0; float preferredWidth = 0; float preferredHeight = 0; // Only measure once. Thereafter, we'll just use cached values. // // We need to copy the cached values into the measured fields // again to handle the case where scaleX or scaleY is not 1.0. // When the ViewStack is zoomed, code in Component.measureSizes // scales the measuredWidth/Height values every time that // measureSizes is called. (bug 100749) if (null != _vsPreferredWidth && !_resizeToContent) { MeasuredMinWidth = (float)_vsMinWidth; MeasuredMinHeight = (float)_vsMinHeight; MeasuredWidth = (float)_vsPreferredWidth; MeasuredHeight = (float)_vsPreferredHeight; return; } if (NumberOfChildren > 0 && SelectedIndex != -1) { Component child = (Component)GetChildAt(SelectedIndex); minWidth = child.MinWidth; preferredWidth = child.GetExplicitOrMeasuredWidth(); minHeight = child.MinHeight; preferredHeight = child.GetExplicitOrMeasuredHeight(); } float wPadding = (int)GetStyle("paddingLeft") + (int)GetStyle("paddingRight"); minWidth += wPadding; preferredWidth += wPadding; float hPadding = (int)GetStyle("paddingTop") + (int)GetStyle("paddingBottom"); minHeight += hPadding; preferredHeight += hPadding; MeasuredMinWidth = minWidth; MeasuredMinHeight = minHeight; MeasuredWidth = preferredWidth; MeasuredHeight = preferredHeight; //Debug.Log(string.Format("MeasuredWidth: {0}, MeasuredHeight: {1}", MeasuredWidth, MeasuredHeight)); // Don't remember sizes if we don't have any children if (NumberOfChildren == 0) { return; } _vsMinWidth = minWidth; _vsMinHeight = minHeight; _vsPreferredWidth = preferredWidth; _vsPreferredHeight = preferredHeight; }