是否可以从外部aar库覆盖android字符串资源? [英] Is it possible to override android string resource from external aar library?
问题描述
我有一个依赖第三方库(aar)的项目.我想更改此库中的某些字符串(它们在该库的strings.xml中定义).是否可以在不处理库源代码的情况下覆盖这些字符串值?(已知字符串资源的ID).
I have a project that depends on third-party library (aar). I want to change some strings in this library (they are defined in strings.xml of the library). Is it possible to override these string values without dealing with library source code? (id of the string resource is known).
推荐答案
是,您可以做到这一点,但是您必须覆盖所有使用该字符串编写的语言.
Yes, you can do it, but you have to override all languages in which the string is written.
假定以下字符串位于 res/values
文件夹中的第三方库中.
Assume that the following string is in a third-party library in res/values
folder.
<string name="msg">Message</string>
这位于库 res/values-it
文件夹中:
<string name="msg">Messaggio</string>
您必须在应用程序中覆盖两者,因此,在您的 res/values
文件夹中,您可以执行以下操作:
You have to override both in your app, so, in your res/values
folder, you can do:
<string name="msg">My new string</string>
在 res/values-it
中,您可以执行以下操作:
And in res/values-it
, you can do:
<string name="msg">La mia stringa</string>
这篇关于是否可以从外部aar库覆盖android字符串资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!