Issue
I have an android fragment app/src/main/res/layout/fragment_main.xml
that references a color bg_line
defined in app/src/main/res/values/colors.xml
res/values/colors.xml
:
<resources> <color name="bg_line">#E7E7E7</color> ...
fragment_main.xml
:
<RelativeLayout android:background="@color/bg_line" ... >...
I want to refactor my existing working code and move color bg_line
into a different android library module
mylib/src/main/res/values/colors.xml
that uses
mylib/src/main/manifest.xml
:
<manifest package="de.k3b.mylib" ...>
My Question: how can i reference the color bg_line
in fragment_main.xml
if bg_line
is defined in modul :mylib
in https://developer.android.com/guide/topics/resources/color-list-resource i found
> resource reference: > In Java: R.color.filename > In XML: @[package:]color/filename
- I found no example use for [package:]
i tried
- android:background="@android:color/bg_line"
- android:background="@app:color/bg_line"
- android:background="@mylib:color/bg_line"
- android:background="@de.k3b.mylib:color/bg_line"
I am using Android Studio (Electric Eel | 2022.1.1 Patch 2)
Solution
the module that contains the layout fragment main.xml must implement (gradle) the module (:mylib) where the color definition is found. So it's just referencing the color as "before" (android:background="@color/bg_line").
Answered By - Petruceli.L
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.