Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android data binding vs findViewById for performance

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 ?

like image 942
j2emanue Avatar asked Jan 11 '16 01:01

j2emanue


1 Answers

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.

like image 62
j2emanue Avatar answered Oct 29 '22 20:10

j2emanue