我收到以下错误消息
android.content.res.Resources$NotFoundException: If the resource you are trying to use is a vector resource, you may be referencing it in an unsupported way. See AppCompatDelegate.setCompatVectorFromResourcesEnabled() for more info.
当我尝试设置以下:
view.setBackgroundResource(R.drawable.highlight_background);
或
view.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.highlight_background));
我也使用AppCompatImage尝试。这发生在Android 4.4.4的设备上。我发现另一个StackOverflow的线程提供补充
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
成MyApplication的类和
vectorDrawables.useSupportLibrary = true
到的build.gradle。但错误仍然存在。 drawable由以下几部分组成:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dp" android:color="?attr/colorAccent" />
</shape>
这只是一条包围图像的线。谁能帮我?
在此先感谢!
你的问题是android_color = attr/colorAccent“”行,看下面的链接 –