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

raghuramjampala

08/15/2019, 2:25 PM
Hi all, I have created an internal view which should only be used in the module where it is created, but I can see it in xml in the other module which has the dependency (It is hidden from kotlin but visible from XML). How Do I make it hidden from the other module’s xml as well?
a

Adam Powell

08/15/2019, 2:42 PM
You can't without implementing your own
LayoutInflater
to enforce the restriction.
LayoutInflater
will reflectively inflate anything available in the classloader.
convention is usually to put
internal
in the package name so that if someone does it anyway, it looks wrong. e.g.
com.example.mymodule.internal.MyView
r

raghuramjampala

08/15/2019, 2:45 PM
just wondering if it works in way that I just have an internal class and I create a view from context and build the view from kotlin, do you think that would stop it form being visible?
c

czuckie

08/15/2019, 2:50 PM
I think you can make a public.txt to describe which resources you want public from an AAR
that's how the androidx aars mark resources as public I believe
r

raghuramjampala

08/15/2019, 2:56 PM
But my issue is with actual custom kotlin class unlike the xml resources
c

czuckie

08/15/2019, 2:56 PM
I completely misunderstood what you asked, apologies
r

raghuramjampala

08/15/2019, 2:57 PM
No problem, thanks for trying to help
4 Views