Android data binding vs findViewById for performance

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

I realize the potential for android data binding for MVVM is great and it opens doors. But regarding performance, is data binding faster then using findViewById in native android ?

回答1:

It looks to me that it is faster per the docs:

Views With IDs

A public final field will be generated for each View with an ID in the layout. The binding does a single pass on the View hierarchy, extracting the Views with IDs. This mechanism can be faster than calling findViewById for several Views.

So it seems data binding only has to do a single pass over the view hierarchy instead of us always calling findViewById.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!