码迷,mamicode.com
首页 > 其他好文 > 详细

LayoutInflater.inflate() 参数研究

时间:2016-06-24 01:32:35      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

参考连接:http://blog.csdn.net/lovexieyuan520/article/details/9036673 

http://www.2cto.com/kf/201407/313054.html

http://blog.csdn.net/xyz_fly/article/details/37932989

http://blog.jobbole.com/72156/

 

  inflate方法有4种:这个方法重载了四种调用方式,分别为:

1. public View inflate(int resource, ViewGroup root)

2. public View inflate(int resource, ViewGroup root, boolean attachToRoot)

3.public View inflate(XmlPullParser parser, ViewGroup root)

4.public View inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot)

最终调用第四种方法。  

1当root为空,当前布局不起作用,使用根布局的设置。

2当root不为空(root),attachToRoot为false,才能使用该布局的设置。 当attachToRoot为true,该布局被添加到(如果根布局为垂直排列)(挂载?)根布局中,且保留了其自己的layoutparam参数(即该布局的参数设置)。

 

某1楼总结:

true:并且root存在,将xml挂载到root下,返回root
false:返回xml的跟布局

LayoutInflater.inflate() 参数研究

标签:

原文地址:http://www.cnblogs.com/wosuxiongmao/p/5612626.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!