美文网首页
inflate&Layoutparams

inflate&Layoutparams

作者: pure粹 | 来源:发表于2019-02-27 00:53 被阅读0次

    public View inflate(XmlPullParser parser, @Nullable ViewGroup root,booleanattachToRoot)
    1.root是否为null,决定是否通过root为解析view生成LayoutParams;
    if (root != null) {

        params = root.generateLayoutParams(attrs);

        if (!attachToRoot) {

            temp.setLayoutParams(params);

        }

    }

    2.booleanattachToRoot决定是否直接添加到root。
    if (root !=null && attachToRoot) {

        root.addView(temp, params);
    }

    *如果view没有父view也就是没attachToRoot那么getLayoutParams返回空对象

    相关文章

      网友评论

          本文标题:inflate&Layoutparams

          本文链接:https://www.haomeiwen.com/subject/fhktuqtx.html