gpt4 book ai didi

android - 如何使应用程序的矢量可绘制对象覆盖库的矢量可绘制对象?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:04:42 24 4
gpt4 key购买 nike

我有一个库项目和一个应用程序项目。除了其他内容之外,库项目还包含一些 png 和一些矢量绘图。现在我可以通过给它相同的名称轻松覆盖应用程序项目中的 png 可绘制对象,并且它会正确显示。不过,这不适用于矢量可绘制对象:该应用始终显示库中定义的矢量可绘制对象,无论是在 Android 4 还是 5 上。该应用永远不会显示应用程序项目的矢量可绘制对象。

Google claims an application's resources always have priority over a library's resources :

Since the tools merge the resources of a library module with those of a dependent application module, a given resource ID might be defined in both modules. In this case, the tools select the resource from the application, or the library with highest priority, and discard the other resource. As you develop your applications, be aware that common resource IDs are likely to be defined in more than one project and will be merged, with the resource from the application or highest-priority library taking precedence.

但正如我所说,对于矢量可绘制对象,出于某种原因,情况正好相反。知道我可以做些什么来确保像普通可绘制对象和其他资源一样覆盖矢量可绘制对象吗?

更新:Resolved in support library v23.2 !现在无事可做:)

最佳答案

构建库项目时,VectorDrawable 为每个密度创建 PNG 文件,并将原始 VectorDrawable 放入 drawable-anydpi-v21 .

如果您将 VectorDrawable 放在您应用的 drawable-anydpi-v21 中,那么它将覆盖您的库项目中的可绘制对象。这似乎是一个错误,应该创建一个新问题(如果尚不存在的话)。


注意:这不会替换库中生成的 PNG 文件。您还需要将它们添加到您的应用中以覆盖它们。

关于android - 如何使应用程序的矢量可绘制对象覆盖库的矢量可绘制对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34608197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com