然后你调用view.getMeasuredWidth,view.getMeasuredHeigth 返回的就是上面函数里的mMeasuredWidth,mMeasuredHeight的值。 getChildMeasureSpec: 计算MeasureSpec然后传递到特定的子视图,此方法用来计算一个合适子视图的尺寸大小(宽度或者高度),目的在于结合我们从子视图的LayoutParams所给出的MeasureSpec信息来获取最合适的结果。 比如,如果这个View知道自己的大小尺寸(因为它本身的MeasureSpec的model为Exactly,)并且子视图的大小恰好跟父窗口一样大,父窗口必须用给定的大小去layout子视图 参数:spec 父窗口传递给子视图的大小和模式 padding 父窗口的边距,也就是xml中的android:padding childDimension 子视图想要绘制的准确大小,但最终不一定绘制此值 Does the hard part of measureChildren: figuring out the MeasureSpec to * pass to a particular child. This method figures out the right MeasureSpec * for one dimension (height or width) of one child view. * * The goal is to combine information from our MeasureSpec with the * LayoutParams of the child to get the best possible results. For example, * if the this view knows its size (because its MeasureSpec has a mode of * EXACTLY), and the child has indicated in its LayoutParams that it wants * to be the same size as the parent, the parent should ask the child to * layout given an exact size. * * @param spec The requirements for this view * @param padding The padding of this view for the current dimension and * margins, if applicable * @param childDimension How big the child wants to be in the current * dimension * a MeasureSpec integer for the child