看别人的项目时,发现竟然用这样一种方式构建
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE
查了下资料,才发现原来我们日常所用的
public View inflate (int resource, ViewGroup root, boolean attachToRoot)
的源码就是调用这个方法,原来大牛都是源码控哦!
至于这三个参数的正确使用姿势,root如果不为空,就能获取到layout_开头的属性了。