ViewStub 与 View.GONE

发布于 2024-09-14 21:19:14 字数 117 浏览 2 评论 0原文

据我了解,ViewStubGONE 的 View 都不参与测量和布局过程(或无论如何渲染)。

渲染性能有区别吗?关于何时使用哪个的最佳实践是什么?

As far as I undestand, neither a ViewStub nor a View that's GONE participate in the measure and layout passes (or rendering anyway).

Is there a difference in rendering performance? What's the best practice about when to use which?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

浮生面具三千个 2024-09-21 21:19:14

当您膨胀视图时,渲染性能就会显现出来。

我的猜测是,通过 XML 或更改可见性来扩充 ViewStub 比扩充 View 便宜得多。当您需要添加/删除(不确定)视图(例如,向给定联系人添加电话号码)时,尤其需要使用 ViewStub。希望这就是您正在寻找的。

The rendering performance comes into picture when you are inflating the views.

My guess is that its much cheaper to inflate a ViewStub than to inflate a View, either from XML or by changing visibility. ViewStub is especially used when you need to add/remove (indefinite) views (eg. add phone numbers to a given contact). Hope this is what you were looking for.

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