本文介绍了间&LT差异,包括>和< ViewStub>在机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间有什么与其中的差别; \包括>标签和< \ ViewStub>标记,哪一个是preferrable在设计布局

What are the differences between <\include> tag and <\ViewStub> tag and which one is preferrable while designing the layout.

谢谢,
VENU

Thanks,
venu

推荐答案

在&lt;包括/>将只包含XML内容的基础xml文件,就好像整个事情只是一个大的文件。这是一个不错的方式来分享不同的布局之间的布局部分。

The < include /> will just include the xml contents in your base xml file as if the whole thing was just a single big file. It's a nice way to share layout parts between different layouts.

的&lt; ViewStub />是一个有点不同,因为它不直接引用,并只会加载当你真正使用它/需要它,也就是说,当你设定的能见度可见 (实际上可见)或看不见(仍然不可见,但其大小不是0了)。这是一个很好的优化,因为你可以有吨的小型观点或标题的任何地方一个复杂的布局,仍然有你的活动加载非常快。一旦你使用这些视图之一,它会被加载。

The < ViewStub /> is a bit different because it is not directly included, and will be loaded only when you actually use it/need it, ie, when you set its visibility to VISIBLE (actually visible) or INVISIBLE (still not visible, but its size isn't 0 anymore). This a nice optimization because you could have a complex layout with tons of small views or headers anywhere, and still have your Activity load up really fast. Once you use one of those views, it'll be loaded.

这篇关于间&LT差异,包括&GT;和&lt; ViewStub&GT;在机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 06:04