我听说 PRODUCT_PACKAGE_OVERLAYS 可用于将字符串添加到 native Android 应用程序,而无需实际编辑该应用程序的 strings.xml。
我尝试按照 this site 中的步骤操作(我创建了/vendor/.. 等),但是当我尝试在 Activity 中使用字符串时出现构建错误。
如何在我的 Activity 中调用覆盖层中声明的字符串(例如:R.string.x)?
谢谢。
最佳答案
我找到了这个网站,http://mmmyddd.github.io/wiki/android/overlay.html
谈论Android Overlay机制。
有两种类型的覆盖目录会影响产品:
PRODUCT_PACKAGE_OVERLAYS
:由特定产品使用DEVICE_PACKAGE_OVERLAYS
:由共享通用设备型号的多个产品使用
如果 PRODUCT_PACKAGE_OVERLAYS
包含相同的资源,则它们将覆盖 DEVICE_PACKAGE_OVERLAYS
。
使用 Android SDK 工具aapt,您将看到:
-S directory in which to find resources. Multiple directories will be scanned and the first match found (left to right) will take precedence.
至于如何添加额外的资源,我们可以通过在aapt中添加选项auto-add-overlay来实现
--auto-add-overlay Automatically add resources that are only in overlays.
关于android - 如何: PRODUCT_PACKAGE_OVERLAYS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9372407/