为了账号安全,请及时绑定邮箱和手机立即绑定

父容器调用getChildMeasureSpec的时候传入的第二个参数好像不止是子view的padding吧?这是怎么回事?

父容器调用getChildMeasureSpec的时候传入的第二个参数好像不止是子view的padding吧?这是怎么回事?

qq_浪子回头_3 2017-05-04 00:55:55
/** * Ask one of the children of this view to measure itself, taking into * account both the MeasureSpec requirements for this view and its padding * and margins. The child must have MarginLayoutParams The heavy lifting is * done in getChildMeasureSpec. * * @param child The child to measure * @param parentWidthMeasureSpec The width requirements for this view * @param widthUsed Extra space that has been used up by the parent *        horizontally (possibly by other children of the parent) * @param parentHeightMeasureSpec The height requirements for this view * @param heightUsed Extra space that has been used up by the parent *        vertically (possibly by other children of the parent) */protected void measureChildWithMargins(View child,        int parentWidthMeasureSpec, int widthUsed,        int parentHeightMeasureSpec, int heightUsed) {    // 1 类型转换    final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();      // 2 getChildMeasureSpec方法    final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,            mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin                    + widthUsed, lp.width);    final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec,            mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin                    + heightUsed, lp.height);      child.measure(childWidthMeasureSpec, childHeightMeasureSpec);}/** * @param spec 父View的详细测量值(MeasureSpec) * @param padding  子view内外边距 *@param childDimension 子view预定的大小(LayoutParam.width或height)---最终不一定绘制该大小 *子布局大小需要由自身的layoutPrams属性和父View的MeasureSpec共同决定 */ViewGroup.getChildMeasureSpec(int spec, int padding, int childDimension);
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1110 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信