How to use vector drawables with View besides ImageView with srcCompat?

后端 未结 9 958
旧巷少年郎
旧巷少年郎 2020-12-13 03:45

app:srcCompat with ImageView allows for backward compatible use of vector drawables. But how can you use them with other Views besides

9条回答
  •  粉色の甜心
    2020-12-13 04:31

    Android 5.0 (API level 21) and higher provides vector drawable support. If your app has a minimum API level that is lower, Vector Asset Studio adds the vector drawable file to your project; also, at build time, Gradle creates PNG raster images at various resolutions. Gradle generates the PNG densities specified by the Domain Specific Language (DSL) generatedDensities property in a build.gradle file. To generate PNGs, the build system requires Android Plugin for Gradle 1.5.0 or higher.

    This is not true if you include in your gradle vectorDrawables.useSupportLibrary = true

    either set to false or remove the line completely and all your vectors will work as they were. But for olders versions of android they will be able to rely on the converted PNG

提交回复
热议问题