Very long vector path
2 min readDec 6, 2020
Problem:
This lint warning is shown by Android Studio for SVG
Very long vector path (1034 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.
Wrong Solutions:
1. Add tools:ignore=”VectorPath”
<path
android:pathData="m512,256c0,141.387 -114.613"
android:fillColor="#42b7a1"
tools:ignore="VectorPath" />
Doing this will just suppress the lint warning it won’t solve the real problem.
Note:
tools
namespace enable design-time features (such as which layout to show in a fragment) or compile-time behaviors (such as which shrinking mode to apply to your XML resources).
2. Extract String Resource of that long vector path like this
<path
android:pathData="@string/qwertyuiop"
android:fillColor="#2f373b"/><string name="qwertyuiop">m439.738,122.469c17.59,-28.34 -36.16,-49.848 -36.16,-49.848s25.773,-1.543 17.594,-22.48c-8.781,-22.48 -75.262,0 -75.262,-22.48 0,-22.48 -34.211,-15.629 -89.91,5.871 -55.699,-21.5 -89.91,-28.352 -89.91,-5.871 0,22.48 -67.109,0 -75.262,22.48 -7.656,21.141 17.594,22.48 17.594,22.48s-53.75,21.508 -36.16,49.848c17.59,28.34 32.258,15.641 24.93,35.672 -7.34,20.039…