Is it possible to override android string resource from external aar library?

℡╲_俬逩灬. 提交于 2021-01-28 01:23:11

问题


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).


回答1:


Yes, you can do it, but you have to override all languages in which the string is written.

Assume that the following string is in a third-party library in res/values folder.

<string name="msg">Message</string>

And this is in the library res/values-it folder:

<string name="msg">Messaggio</string>

You have to override both in your app, so, in your res/values folder, you can do:

<string name="msg">My new string</string>

And in res/values-it, you can do:

<string name="msg">La mia stringa</string>


来源:https://stackoverflow.com/questions/43694575/is-it-possible-to-override-android-string-resource-from-external-aar-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!