1.getLayoutInflater().inflate() 与 View.inflate() 以及 LayoutInflater.from(this).inflate() 最终都是调用都是同一个方法。
2.使用 View.inflate() 时,root 传 null,则生成的 View 宽高均为 wrap_content,并不会根据设定的 layout_width 和 layout_height 去显示;若 root 不为空,则会将想要生成的 view 直接添加到 root 中,并返回 root。
3.使用 getLayoutInflater().inflate() 时,若 root 不为空,同时 attachToRoot 为 false,则生成的 View 宽高为设定的 layout_width 和 layout_height 去显示;若 root 为空,attachToRoot 为 false,则生成的 View 宽高均为 wrap_content。
Android中getLayoutInflater().inflate()和inflater.inflate()的区别
最新推荐文章于 2024-04-16 14:39:27 发布
251

被折叠的 条评论
为什么被折叠?



