使用支持库23.2,一直到API v7都对Vector Drawables提供了真正的支持。建议通过添加以下内容来禁用该支持的先前版本:该支持在??构建期间呈现PNG
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
到build.gradle
文件。
实现非常简单。只需在Drawables上使用新的srcCompat属性即可:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_add" /> <= this is new