Suppose in a project I have 10 XML file. Within 3 of them don't require data binding feature i.e., we just need the reference of views, thus don't need to wrap all the three XMLs into <layout>...</layout>
tag.
So is it a good idea to use both view binding
and data binding
, or just the data binding
as it's superior of view binding
?
P.S: Wrapping up into <layout>...</layout>
is not a big deal, but I am asking for best practices we should follow.
The answer to your question is yes, you can use data-binding and view-binding together, but it's not recommended because it significantly impacts your build time. There is nothing view-binding can do that data-binding cannot.
You can check this link that compares these two approaches and explains the differences, but normally view-binding can be a better choice due to a lower build time and better effectiveness.