Android.Views.View.OnMeasure Method

Syntax

[Android.Runtime.Register("onMeasure", "(II)V", "GetOnMeasure_IIHandler")]
protected virtual void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)

See Also

View.MeasuredWidth
View.MeasuredHeight
View.SetMeasuredDimension(int, System.Int32)
View.SuggestedMinimumHeight
View.SuggestedMinimumWidth

Parameters

widthMeasureSpec
horizontal space requirements as imposed by the parent. The requirements are encoded with NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html.
heightMeasureSpec
vertical space requirements as imposed by the parent. The requirements are encoded with NoType:android/view/View$MeasureSpec;Href=../../../reference/android/view/View.MeasureSpec.html.

Remarks

Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.Measure(int, System.Int32) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call View.SetMeasuredDimension(int, System.Int32) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.Measure(int, System.Int32). Calling the superclass' View.OnMeasure(int, System.Int32) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override View.OnMeasure(int, System.Int32) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (View.SuggestedMinimumHeight and View.SuggestedMinimumWidth).

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1