lootinflater中根的目的
根据我的理解,
layoutinflater.inflate(资源,root,actacttoroot): - 这只是为了将XML转换为视图对象。
我的问题是,由于Attrate()与root
参数无关。 .my_custom_view,null,false)没有任何错误?
上述原因是,getView(..)
仅负责返回根据位置构建的动态视图,它不负责将此构造的视图附加到父viewgroup。
As per my understanding,
LayoutInflater.inflate(resource, root, attachToRoot):- It's job is JUST to convert the XML to the Views object.
My question is, since inflate() is not concerned with root
parameter if we are passing attachToRoot = false
, then can we use LayoutInflater.inflate(R.layout.my_custom_view, null, false)
without any blunder?
The reasoning behind the above is, getView(..)
is only responsible for returning the dynamic view which is constructed according to the position, it isn't responsible for attaching this constructed View to the parent ViewGroup.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根视图也会影响布局。夸大的视图可以相对于其父级的大小和定位(例如,
match_parent
size param),并且root视图参数即使视图没有(尚未)作为布局目的的父行动(尚未)()添加到它。The root view can also affect the layout. The inflated view can be sized and positioned relative to its parent (for example,
match_parent
size param), and the root view parameter works as the parent for layout purposes even if the view doesn't (yet) get added to it.