在你的模块build.gradle
文件中,你需要添加这行代码:
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
vectorDrawables.useSupportLibrary = true // This line here
}
...
}
...
在defaultConfig
块下添加以下行到你的Gradle文件中:
vectorDrawables.useSupportLibrary = true
此外,在每个引用了srcCompat
中的图片而不是drawable的活动或片段中,您需要添加以下代码块:
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
您需要在您的应用程序级别的build.gradle文件中的defaultConfig
标签内添加vectorDrawables.useSupportLibrary = true
这行代码。
defaultConfig {
applicationId "your package Name"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "0.0.1"
//This is the Main Line you have to add to avoid this warning.
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
android:src="@drawable/edit"
在你的ImageButton中添加:
tools:ignore="VectorDrawableCompat"