The essence of measure is to translate the relative values of the attempted layout into concrete values.
The Measurespec class wraps the layout requirements passed down from the parent, and each measurespec represents a requirement for width and height.
Why does a layout require a parent view and a child view to decide together? Why not set width and height directly? If this is not the case, specify a fixed size like HTML, which will cause one to go through a lot of other extrusion. Because HTML is control over the entire page. While Android is split, this ensures that the end-of-the-line (interface development) affects the layout of the other tiers and needs to follow (control development) rules. View.setwidth, View.setheight? No
Need to pass Measurechilde (view, width, height), or childview.measure ();
View.getwidth (), View.gethight ()
View.getmeasurewidth (), View.getmeasurehiegh ()
One that was not added to the view? But sometimes the getmesureheight still returns 0. Why? The EC is an internal class of Android.view.View that encapsulates the layout requirements information that is passed from the parent class to the subclass.
Measure methods provided by ViewGroup
Measurechildren ()-The function uses a for () Loop call Measurechild () to measure each sub-view measurechild ()- Measure operation for each sub-view measurechildwidthmargins ()-The only difference between this function and measurechild is that measure consider margin and padding as part of the child view size
There is a convention: When you overwrite the Onmeasure method, you must call Setmeasureddimension (Int,int) to store The view's measured measured width and height. If this is not done. A illegalstateexception will be thrown by the measure (int, int) method.
Measure (int widthmeasurespec, int heightmeasurespec), since the picture is square, the width and height values are the same.
When covering the Onmeasure method, the subclass is responsible for ensuring that the measured height width is at least the minimum height and width of the view.
Setmeasureddimension (Reswidth, resheight);
Gets the minimum available value for this control, if Android:minwidth is set, based on the size of the diagram you set.
If there is no background map, then the default size, the default is the screen width and high school small value
android--Custom ViewGroup ()