可绘制矢量不会被构建变体尺寸覆盖

时间:2019-07-26 21:44:35

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

我有一个带有基本品牌和多个whitelabel品牌以及多个服务器目标的应用。在我的应用程序的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,即使在Whitelabel1的apk中,ImageView也会从main渲染logo.xml

<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" />

1 个答案:

答案 0 :(得分:0)

这件事也发生在我身上。只有写完这个 vectorDrawables.useSupportLibrary = true 在defaultconfig中。从flavor source set文件夹中选择了矢量资源。

相关问题