对不同的风味维度使用不同的图标
Using different icon for different flavor dimension
我为 Android 应用程序创建了两种风格和两个维度。口味是免费的和高级的,尺寸是默认的和有额外的。我想要的是以下口味:
freeDefault
|---freeWithExtras
premiumDefault
|---premiumWithExtras
withExtras 维度应该基于默认风格,但添加了更多功能。我还希望 freeWithExtras 版本有一个不同的图标。我创建了一个不同的图标并将其放在 src/withExtras/res/drawable 文件夹中。另一个(默认)图标位于 src/free/res/drawable 文件夹中。当我 运行 freeWithExtras 维度时,使用的图标来自 free/res/drawable 文件夹。如何使上述维度使用放置在其 res 文件夹中的图像?我的设置有问题吗?
我假设您的风格/维度设置如下所示:
flavorDimensions "mode", "extras"
...
productFlavors {
free {
dimension "mode"
}
premium {
dimension "mode"
}
default {
dimension "extras"
}
withExtras {
dimension "extras"
}
}
您应该能够为您的特定构建变体创建一个源文件夹 freeWithExtras
,它结合了两种风格。然后你可以将你的图标放入src/freeWithExtras/res
。 The order you specify your flavorDimensions
controls the order in which the flavors are concatenated 构建文件夹/构建变体名称。
我为 Android 应用程序创建了两种风格和两个维度。口味是免费的和高级的,尺寸是默认的和有额外的。我想要的是以下口味:
freeDefault
|---freeWithExtras
premiumDefault
|---premiumWithExtras
withExtras 维度应该基于默认风格,但添加了更多功能。我还希望 freeWithExtras 版本有一个不同的图标。我创建了一个不同的图标并将其放在 src/withExtras/res/drawable 文件夹中。另一个(默认)图标位于 src/free/res/drawable 文件夹中。当我 运行 freeWithExtras 维度时,使用的图标来自 free/res/drawable 文件夹。如何使上述维度使用放置在其 res 文件夹中的图像?我的设置有问题吗?
我假设您的风格/维度设置如下所示:
flavorDimensions "mode", "extras"
...
productFlavors {
free {
dimension "mode"
}
premium {
dimension "mode"
}
default {
dimension "extras"
}
withExtras {
dimension "extras"
}
}
您应该能够为您的特定构建变体创建一个源文件夹 freeWithExtras
,它结合了两种风格。然后你可以将你的图标放入src/freeWithExtras/res
。 The order you specify your flavorDimensions
controls the order in which the flavors are concatenated 构建文件夹/构建变体名称。