非常棒的是,现在通过使用支持库 23.2.0,Lollipop 之前的设备也可以使用 VectorDrawables。虽然我在 API 21+ 上遇到了图像显示问题,但在低版本设备上一切正常。我正在使用 Gradle 插件 1.5,因此我的 build.gradle 包含以下内容:
// Gradle Plugin 1.5
android {
defaultConfig {
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
然后我在我的布局中使用下面的代码:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/my_vector_drawable" />
我在父ViewGroup中声明了这个属性:
xmlns:app="http://schemas.android.com/apk/res-auto"
但是Android Studio仍然显示这个错误,但项目可以构建和运行
"意外的名称空间前缀“app”在标记ImageView中找到"
这是新支持库的一个bug还是我做错了什么?