美文网首页
RecyclerView控件列表项布局match_parent属

RecyclerView控件列表项布局match_parent属

作者: 贝贝ovo | 来源:发表于2017-04-26 22:56 被阅读20次

http://blog.csdn.net/ll530304349/article/details/52605202

http://blog.csdn.net/overseasandroid/article/details/51840819

跟着两篇文章源码分析走一遍,就完全明白了。

        View view=LayoutInflater.from(parent.getContext()
.inflate(R.layout.sample, parent, false);
        return new ViewHolder(view, parent.getContext());
    }

LayoutInflater的 inflate(int resource, ViewGroup root, boolean attachToRoot)

第一个参数 item的布局文件
第二个参数 item的父视图(有父视图才能 测量 绘制 布局子item)
第三个参数 item是否加入到root中 再看这篇文章 (结合第二篇文章的源码分析,这里我们传false,RecycleView内部ChildHelper会addView所有的子child的)

相关文章

网友评论

      本文标题:RecyclerView控件列表项布局match_parent属

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