I am exploring new Android View Binding library.
In my layout XML file, some views that I don't want to include in my binding class.
Does there any attribute or mechanism exist that exclude views into generated Binding class?
ViewBinding vs DataBindingThe main advantages of viewbinding are speed and efficiency. It has a shorter build time because it avoids the overhead and performance issues associated with DataBinding due to annotation processors affecting DataBinding's build time.
View binding is a feature that allows you to more easily write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module.
To enable view binding, configure viewBinding in your module-level build. gradle file. Once enabled for a project, view binding will generate a binding class for all of your layouts automatically. You don't have to make changes to your XML — it'll automatically work with your existing layouts.
We can use tools:viewBindingIgnore=”true/false”
to include and exclude view in generated view binding class.
Usage:
<LinearLayout
...
tools:viewBindingIgnore="true" >
...
</LinearLayout>
Check more about View Binding on below link:
https://developer.android.com/topic/libraries/view-binding#setup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With