最近在使用RecycleView的时候,发现item的布局填充使用
View.inflate(context, resource, null);//inflate(Context context, int resource, ViewGroup root)
设置的item布局属性没有用,
但是使用
LayoutInflater.from(context).inflate(resource,parent,false);//inflate(int resource, ViewGroup root, boolean attachToRoot)就会实现想要的效果
所以为什么呢,于是查阅资料发现
View.infalate(context,resource,root)最终调用的是LayoutInfalter.from(context).infalte(resource,null,false);
item需要获得parent的layoutparams来给自己定位属性
如果没有,系统默认为wrap_content,出现的效果就是自己包括自己