https://kotlinlang.org logo
#android
Title
# android
s

sriram

07/14/2020, 12:54 AM
For Folks using ViewBinding -- I have a question, I am not sure if this is a bug. We have been using ViewBinding and so far it looks good, however, for a scenario where I wanted to include layouts that reside in a different library(AAR) in my app's current layout, unfortunately my binding variable has no visibility of the views that are available within the included layout, is this a known issue or is there any other way?
l

Loboda Deni

07/14/2020, 5:00 AM
Do you want to add your variable to the layout obtained from arr?
s

sriram

07/14/2020, 5:48 AM
Yes, let's say my main layout is
activity_main.xml
, and in that, I have something like this.
Copy code
<include
  android:id="@+id/toolbar"
layout="@layout/layout_from_external_lib"
/>
Now in my activity, the
binding
variable has no visibility of the views that are within in this layout
layout_from_external_lib
l

Loboda Deni

07/14/2020, 5:59 AM
most likely, you will need to specify those variables in your layout.xml and pass from the to the connected layout via the app attribute.
If it's not clear, I can throw off an example
s

sriram

07/14/2020, 6:01 AM
That would be helpful, thanks!
an example i mean
l

Loboda Deni

07/14/2020, 6:12 AM
main.txt,your_included_layout.txt
j

Javier

07/14/2020, 11:09 AM
That is databinding, not viewbinding @Loboda Deni
l

Loboda Deni

07/14/2020, 11:13 AM
sorry i didn't notice
s

sriram

07/14/2020, 2:12 PM
Yeah, this was for ViewBinding.
j

Javier

07/14/2020, 2:17 PM
I think you can do nothing, except you can fork the original library and enable viewBinding
s

sriram

07/14/2020, 2:23 PM
The original library is an internal one, perhaps i can enable ViewBinding in that and try it out.
j

Javier

07/14/2020, 2:24 PM
Ah, if it is yours, just enable viewBinding and it will generate the bindings inside the build folder of that module
💯 1