Difference between and in android

后端 未结 4 836
清歌不尽
清歌不尽 2021-01-03 22:26

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

Thanks,
venu

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 23:06

    Sharing and reusing layouts is very easy with Android thanks to the tag, sometimes even too easy and you might end up with user interfaces that contain a large number of views, some of which are rarely used. Thankfully, Android offers a very special widget called ViewStub, which brings you all the benefits of the without polluting your user interface with rarely used views.

    A ViewStub is a dumb and lightweight view. It has no dimension, it does not draw anything and does not participate in the layout in any way. This means a ViewStub is very cheap to inflate and very cheap to keep in a view hierarchy. A ViewStub can be best described as a lazy include. The layout referenced by a ViewStub is inflated and added to the user interface only when you decide so.

提交回复
热议问题