是否可以从外部aar库覆盖android字符串资源? [英] Is it possible to override android string resource from external aar library?

查看:108
本文介绍了是否可以从外部aar库覆盖android字符串资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖第三方库(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆