//兼容svg 5.0之前
// vectorDrawables.generatedDensities("xhdpi")
//兼容v 7
vectorDrawables.useSupportLibrary = true
第一种方法 第二种方法都可以
第一种原理是生成png图片达到兼容
第二种要修改图片的加载方式
<ImageView
android:layout_width="wrap_content"
android:tint="@color/colorAccent"
app:srcCompat="@drawable/ic_a"
android:layout_height="wrap_content"/>
位置
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.2'
}