Issue
I'm a little bit confused how multiple dimens.xml
files (not for different screen resolutions and sizes, but from multiple library modules) are handled in AndroidStudio.
I have an AndroidStudio project which consists of one main module (the runnable app) and several library modules, lets call them module1
and module2
.
From a xml file in my main module's layout folder I try to access a value stored in dimens.xml
of module2
like for example this android:paddingBottom="@dimen/..."
, but I can only find dimens from module1
and the main module itself.
My question is, how can I access the dimen values from the main module and all library modules? Why is it, that I get suggestions for the main modules' and module1's
values but not for module2
?
I'd appreciate any clarification on that.
Solution
The Android Gradle plugin and Android Studio recently made a change to support the concept of public and private resources in library projects.
This allows libraries to hide their resources from consuming applications, preventing polluting the resources namespace and preventing consumers from using resources that might change in future versions of the library.
By default, all resources in a library project are private.
To make a resource public, create a new res/values/public.xml
resource file and put a definition in that file like so:
<resources>
<public name="libraryname_dimen" type="dimen"/>
</resources>
This would make a dimension resource called libraryname_dimen
public and thus available to other modules and/or consuming applications if you were to publish the AAR.
You can read more at the Private Resources tools documentation.
Answered By - Bryan Herbst
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.