-
Notifications
You must be signed in to change notification settings - Fork 9
Path fill rule support
VectorDrawable path fill-rule is always non-zero and cannot be changed prior to Android 7.0 (Nougat, API level 24).
If you end up with areas filled that should not be filled, that is because the SVG image was created using even-odd rule instead.
There are three ways to deal with this problem: try specifying the Fix fill type
option, manually edit SVGs in vector graphics software or convert for Android 7.0+.
This option is experimental, but it is worth trying first (if fails, please open an issue). The option uses advanced mathematics to rebuild paths in such a way that rendering with any fill rule leads to the same result.
The converter suggests specifying the option if necessary. Slows down conversion when enabled.
If you are using Inkscape, open Object → Fill and Stroke… and in the Fill tab choose Fill is solid unless a subpath is counterdirectional. If you see an improperly filled area after this operation, using F2 tool select subpath around that area and apply Path → Reverse command from the main menu.
If you are using Sketch, select the path, right to the Fills property title there is a settings icon, click it and choose Non-Zero option. To reverse the path direction apply Layer → Paths → Reverse Order command from the main menu.
By default, for older devices, Android Studio generates PNG images at build time. Alternatively, you can try AndroidX VectorDrawableCompat.
It won't help if a clipping path uses the even-odd fill-rule.