很高兴 Lollipop 之前的设备现在可以通过支持库 23.2.0 使用 VectorDrawables。虽然我在 API 21+ 上有图像显示问题,但在低端设备上一切正常。我使用的是 Gradle Plugin 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" />
我已经在我 parent 的 ViewGroup 中声明了这个属性:
xmlns:app="http://schemas.android.com/apk/res-auto"
但是 Android Studio 仍然显示这个错误,但是项目可以构建和运行
"Unexpected namespace prefix "app" found for tag ImageView"
这是新支持库的错误还是我做错了什么?
最佳答案
要解决您的图像缩放问题,您是否尝试过将 scaleType='fitXY'
设置到您的 ImageView?
(您现在可以安全地忽略该 Lint 错误,同时将 tools:ignore="MissingPrefix"
添加到您的 ImageView)。
关于android - 在 API 21+ 上使用带有 srcCompat 的 VectorDrawables 将 Android 支持库更新到 23.2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35814680/