lootinflater中根的目的

发布于 2025-02-12 23:43:39 字数 254 浏览 1 评论 0原文

根据我的理解,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦上情书 2025-02-19 23:43:39

根视图也会影响布局。夸大的视图可以相对于其父级的大小和定位(例如,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文