【问题标题】:Vector Drawable Not Overwritten by Build Variant Flavor Dimension构建变体风味维度未覆盖的矢量可绘制对象
【发布时间】:2019-12-05 05:29:00
【问题描述】:

我有一个具有基本品牌和多个白标品牌以及多个服务器目标的应用。在我的应用程序的 build.gradle 中,风味定义为: flavorDimensions("server", "whitelabel")

在我的 src/main/res/drawable 中,我有一个用于基本品牌的 logo.xml VectorDrawable,它在 src/whitelabel1/res/drawable 中被覆盖。

当我的应用程序的 build.config 包含 vectorDrawables.useSupportLibrary = true 时,我的 ImageView 中使用了正确的 logo.xml。如果我删除 useSupportLibrary,ImageView 会从 main 呈现 logo.xml,即使是在 Whitelabel1 的 apk 中

<ImageView
    android:id="@+id/imageLogo"
    android:layout_width="@dimen/viewXS"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/marginXS"
    android:adjustViewBounds="true"
    android:padding="@dimen/marginXS"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/ic_logo" />

【问题讨论】:

    标签: android android-gradle-plugin android-vectordrawable build-variant


    【解决方案1】:

    这也发生在我身上。只有在写完这个之后 vectorDrawables.useSupportLibrary = true 默认配置里面。矢量资源是从风味源集文件夹中挑选出来的。

    【讨论】:

    • edit您的答案以改进代码格式,并解释其工作原理以及为什么它是问题中描述的问题的解决方案。见How to Answer
    • 对于像 PNG 这样的非矢量可绘制对象也是如此吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 2021-07-28
    • 2016-11-04
    • 2016-05-25
    • 2015-10-09
    • 1970-01-01
    相关资源
    最近更新 更多