For vector.xml
<vector ...>
<path
android:fillColor="@android:color/white"
android:pathData=""/>
</vector>
Note the android:fillColor="@android:color/white" part, this color is not supported by this tool, but replaced with Color.Black in the generated code without any error or warning.
The generated kotlin code is:
val ImIcBatchSelectUnchecked: ImageVector
get() {
...
path(fill = SolidColor(Color.Black)) { // <=== note here
...
}
The hex color parse logic is in HexParser:
fun toColorInt(value: String): Int {
val hex = value.removePrefix("#").removePrefix("0x")
val normalizedHex = if (hexRegex.matches(hex)) {
when (hex.length) {
3 -> "FF${expandShorthandHex(hex)}"
6 -> "FF$hex"
8 -> hex
else -> DEFAULT_COLOR
}
} else {
DEFAULT_COLOR
}
return normalizedHex.toUInt(16).toInt()
}
Should we throw an exception instead of returning DEFAULT_COLOR, which is FF000000.
For vector.xml
Note the
android:fillColor="@android:color/white"part, this color is not supported by this tool, but replaced withColor.Blackin the generated code without any error or warning.The generated kotlin code is:
The hex color parse logic is in
HexParser:Should we throw an exception instead of returning
DEFAULT_COLOR, which isFF000000.