不能在依赖库中使用 VectorDrawableCompat
cant use VectorDrawableCompat in dependencied library
我正在使用一些来自 maven 的库,我已经在 gradle(Android Studio)
dependencies {
//...other librarys
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
我想将其用于兼容 VectorDrawable 作为旧 sdk 上 ImageView 的源 和背景 。
但是好像没什么效果。
布局中xml:
xmlns:app="http://schemas.android.com/apk/res-auto"
和
<ImageView
android:id="@+id/svg_head"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/header"/>
这将是一个意外的命名空间前缀应用程序错误,如果我忽略(添加tools:ignore attr),它将无法成功构建。
在java代码中:
我想为兼容背景做这个
Drawable drawable = VectorDrawableCompat.create(getResources(), R.drawable.header, getTheme());
但是class
VectorDrawableCompat
和
AppcompatDrawableManager
完全找不到class(只显示红色名称,没有任何其他提示)
我用其他库很好,请问这是怎么回事???
对于 VectorDrawableCompat 和 AppCompatDrawableManager,您至少需要支持库 v23.2.0
所以改为
compile 'com.android.support:appcompat-v7:23.2.0'
请参阅 this android 开发者博客 post 了解如何使用 gradle 进一步设置它。
我正在使用一些来自 maven 的库,我已经在 gradle(Android Studio)
dependencies {
//...other librarys
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
我想将其用于兼容 VectorDrawable 作为旧 sdk 上 ImageView 的源 和背景 。 但是好像没什么效果。
布局中xml:
xmlns:app="http://schemas.android.com/apk/res-auto"
和
<ImageView
android:id="@+id/svg_head"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/header"/>
这将是一个意外的命名空间前缀应用程序错误,如果我忽略(添加tools:ignore attr),它将无法成功构建。
在java代码中:
我想为兼容背景做这个
Drawable drawable = VectorDrawableCompat.create(getResources(), R.drawable.header, getTheme());
但是class
VectorDrawableCompat
和
AppcompatDrawableManager
完全找不到class(只显示红色名称,没有任何其他提示)
我用其他库很好,请问这是怎么回事???
对于 VectorDrawableCompat 和 AppCompatDrawableManager,您至少需要支持库 v23.2.0
所以改为
compile 'com.android.support:appcompat-v7:23.2.0'
请参阅 this android 开发者博客 post 了解如何使用 gradle 进一步设置它。