现在的位置: 首页 > 综合 > 正文

inflate (int resource, ViewGroup root)关于root 这个参数的最佳解释

2017年12月25日 ⁄ 综合 ⁄ 共 271字 ⁄ 字号 评论关闭

文档:
public View inflate (int resource, ViewGroup root)
....
returns
The root View of the inflated hierarchy. If root was supplied, this is the root View; otherwise it is the root of the inflated XML file.
如果提供root(不传null)时,返回值其实就是这个root,这个方法就是把xml解析成view之后挂载这个root下。
如果传null(不提供root),返回值也是View,它就是xml布局里面的根节点

抱歉!评论已关闭.