public LayoutMeasureSpec(LayoutLength measureSpec, LayoutMeasureSpec.ModeType mode) : this(LayoutPINVOKE.new_MeasureSpec__SWIG_0(LayoutLength.getCPtr(measureSpec), (int)mode), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
private LayoutMeasureSpec.ModeType GetMode() { LayoutMeasureSpec.ModeType ret = (LayoutMeasureSpec.ModeType)LayoutPINVOKE.MeasureSpec_GetMode(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { var accumulatedWidth = new LayoutLength(0); var maxHeight = 0; var measuredWidth = new LayoutLength(0); LayoutLength measuredHeight = new LayoutLength(0); LayoutMeasureSpec.ModeType widthMode = widthMeasureSpec.Mode; LayoutMeasureSpec.ModeType heightMode = heightMeasureSpec.Mode; bool isWidthExact = (widthMode == LayoutMeasureSpec.ModeType.EXACTLY); bool isHeightExact = (heightMode == LayoutMeasureSpec.ModeType.EXACTLY); // In this layout we will: // Measuring the layout with the children in a horizontal configuration, one after another // Set the required width to be the accumulated width of our children // Set the required height to be the maximum height of any of our children for (uint i = 0; i < ChildCount; ++i) { var childLayout = GetChildAt(i); if (childLayout) { MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec); accumulatedWidth += childLayout.MeasuredWidth; maxHeight = System.Math.Max(childLayout.MeasuredHeight.Value, maxHeight); } } measuredHeight.Value = maxHeight; measuredWidth = accumulatedWidth; if (isWidthExact) { measuredWidth = new LayoutLength(widthMeasureSpec.Size); } if (isHeightExact) { measuredHeight = new LayoutLength(heightMeasureSpec.Size); } // Finally, call this method to set the dimensions we would like SetMeasuredDimensions(new MeasuredSize(measuredWidth), new MeasuredSize(measuredHeight)); }