ViewStub 与 View.GONE
据我了解,ViewStub
和 GONE
的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您膨胀视图时,渲染性能就会显现出来。
我的猜测是,通过 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.