on Measure
Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
CONTRACT: When overriding this method, you must call setMeasuredDimension to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException
, thrown by measure. Calling the superclass' onMeasure 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 onMeasure 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 ( getSuggestedMinimumHeight and getSuggestedMinimumWidth).
╔═══════════╗
║┌─────────┐║paddingTop
║│╔═══════╗│║topMargin
║│║ Shift ║│║
║│╚═══════╝│║bottomMargin
╟┼─────────┼╢Split
║│╔═══════╗│║topMargin
║│║Button ║│║
║│╚═══════╝│║bottomMargin
║└─────────┘║paddingBottom
╚═══════════╝
Parameters
horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.