I have an SVG image that I want to include in an Android project.
The minSdk version for the project is 9. Android Studio is generating PNG files for the SVG.
However, for API 21+, Android studio includes the SVG in a drawable-anydpi-v21
resource folder.
That means that any device running API 21 and up will use the SVG instead of the PNGs.
And that is the problem: my SVG requires android:fillType="evenOdd"
.
The PNG are properly generated, but for the SVG, because that attribute is API 24+, it is ignored on API 21 devices, and the image appears filled instead of being a wireframe-like image.
Is there anyway to convince Android studio to only include the PNG and drop the SVG completely?
Is there an other solution for this?
Attribute android:fillType
is only used in API level 24
and higher. For below API level, follow these steps.
add this to your Gradle file.
//Gradle Plugin 2.0+
android {
defaultConfig {
...
vectorDrawables.useSupportLibrary true
}
}
If you are using ImageView
, change its property android:src
to app:srcCompat
.
If you are using as android:drawableStart
or android:drawableEnd
in TextView
, change it to app:drawableStartCompat
or app:drawableEndCompat
.