- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用设计支持库 23.2。我在 build.gradle 中添加了这些行,因为我的 Gradle 插件是 1.5 版
defaultConfig {
applicationId "com.abc.xyz"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
正如 here 中指定的那样
但是我的 ImageView 不能使用 srcCompat 属性。
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:srcCompat="@drawable/wallpaper"/>
其中@drawable/wallpaper 是一个矢量资源文件
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,4h7V2H4c-1.1,0 -2,0.9 -2,2v7h2V4zm6,9l-4,5h12l-3,-4 -2.03,2.71L10,13zm7,-4.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S14,7.67 14,8.5s0.67,1.5 1.5,1.5S17,9.33 17,8.5zM20,2h-7v2h7v7h2V4c0,-1.1 -0.9,-2 -2,-2zm0,18h-7v2h7c1.1,0 2,-0.9 2,-2v-7h-2v7zM4,13H2v7c0,1.1 0.9,2 2,2h7v-2H4v-7z"/>
上面写着
Error:(14) No resource identifier found for attribute 'srcCompat' in package 'android'
我的 Gradle 版本是 1.5。如何使用 srcCompat?
最佳答案
不要
android:srcCompat="@drawable/wallpaper"
做
app:srcCompat="@drawable/wallpaper"
因为它的 srcCompat 属性实际上是在 AppCompat 库中定义的。
重要提示您需要为此添加适当的命名空间。
xmlns:app="http://schemas.android.com/apk/res-auto"
重要
what you are getting it seems like it is just a lint error that can be ignored. I have tried and have the same error, but it is working correctly.
您可以使用 tools:ignore="MissingPrefix"
暂时避免看到此错误。
关于android - 无法在 android 中将 srcCompat 用于 ImageViews,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35645148/
我制作了自己的 progressBar,这样我就可以在 pre-lolipop 中着色,并且在我将可绘制对象从 png 更改为 vector 之前效果很好。我收到长堆栈跟踪错误。正如我在谷歌上搜索的那
最后 Android studio 得到问题: Error:(11) No resource identifier found for attribute 'srcCompat' in package
我正在向库项目添加矢量可绘制支持,并使用 app:srcCompat 来引用矢量可绘制。似乎唯一有效的 View 是 ImageButton,我不确定为什么。 这是我的 build.gradle 的相
我使用带有 XML 设置图标的 float 操作按钮 app:srcCompat="@mipmap/my_image" 我想使用 java,以便如果某个条件为真,FAB 的图标可以更改为类似 my_i
我正在使用 Support Lib v23.2 中的新矢量可绘制对象支持和 app:srcCompat 并尝试通过数据绑定(bind)设置其可绘制对象。
我正在使用支持库在 android kitkat 上显示矢量图像。当我在模拟器上测试我的应用程序时,我看不到任何这些图像。我为 android lollipop 及更高版本做了一个单独的布局,它运行良
在我的 .xml 布局中使用带有矢量可绘制对象的 app:srcCompat 时,我无法在运行 android 4.2.1 的设备上运行代码。例如我有一个像这样的 FAB: 其中 ic_add 是矢
每次我尝试构建或生成签名的 APK 时,我都会收到上述错误。这question类似,但尚未提出可行的解决方案。 我的 BUILD.GRADLE 依赖项的快照: 我的错误日志快照: 支持库已更新 [ ]
我有一个自定义的 ImageView,我正在为其动态绘制背景,例如: @Override protected void onDraw(Canvas canvas){ p.setColor(Sk
我在 RelativeLayout 中有一个 ImageView。 ImageView 的背景是空的,srcCompat 链接到我在可绘制文件夹中的图像。在布局预览中,一切看起来都很好,但是当我在模拟
我在 @drawable 文件夹中使用复制+粘贴添加了 2 张图像,但出现错误 Error:(25) No resource identifier found for attribute 'srcC
我的问题是,有两个显示本地镜像的按钮,但它不呈现,关于在这里做什么有什么想法吗?? ListView 中项目的 XML 文件:
更新到 Studio 2.3 后,当我尝试使用可绘制矢量创建图层列表时,它会提示在 中使用 app:srcCompat 而不是 android:src位图. 谁能帮我把vector drawable添
我在 stackoverflow 上读到关于 app:srcCompat 的信息并且还从其他资源中得知此属性的主要目的是支持矢量绘图。但是当 android:src 也可以很好地使用 vector-d
我在 stackoverflow 上读到关于 app:srcCompat 的信息并且还从其他资源中得知此属性的主要目的是支持矢量绘图。但是当 android:src 也可以很好地使用 vector-d
我要说的是,我已经在 stackoverflow 上看到了这个问题的一些答案,但只是提供了一个快速的“修复”解决方案。如果可能的话,我也想了解为什么会发生这种情况(有一些细节的回答)。 现在开始讨论这
我编写了一个可以发布推文的应用程序,您可以使用它查看用户时间线和搜索时间线。我使用 TwitterAPI 和 Fabric.io 做到了这一点。如果我想生成 APK 文件或同步 Gradle文件,我收
我正在使用设计支持库 23.2。我在 build.gradle 中添加了这些行,因为我的 Gradle 插件是 1.5 版 defaultConfig { applicationId
我遇到了与 VectorDrawables 的新向后兼容性问题。在支持库 23.2 中,引入了向后兼容 Android VectorDrawables 的新功能。 我有一个分配给 SelectorDr
更新为使用 23.3.1 支持库后,布局编辑器不会使用 app:srcCompat 属性渲染 imageView。 Looks like this in the L
我是一名优秀的程序员,十分优秀!