android - 空矢量 Drawable 在运行时导致 ResourceNotFound 异常
问题描述
我不能使用可绘制的空矢量作为占位符:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="164.891"
android:viewportHeight="75.543"
android:width="164.891dp"
android:height="75.543dp"></vector>
Android Studio 没有在 Activity 预览中指出任何渲染问题,但在运行时我得到了这个致命的异常:
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable com.xxxx.yyyy:drawable/product_logo_image with resource ID #0x7f080121
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/product_logo_image.xml from drawable resource ID #0x7f080121
解决方案
更新
您的矢量中没有路径,添加不绘制任何内容的路径应该可以修复错误
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="dp"
android:height="1dp"
android:viewportWidth="1"
android:viewportHeight="1">
<path
android:pathData="M0,0Z"
android:fillColor="#ffffff"/>
</vector>
推荐阅读
- objective-c - 不兼容的指针类型将“struct NSArray *”传递给“NSArray *”类型的参数
- windows - 在 Windows 上的 Docker 容器内运行 Kafka-Manager
- git - Docker 桌面更新后,Docker 容器中出现错误“git cat-file:无法获取对象信息”
- xml - 是否有 xml 命名空间约定?
- go - Beego中如何设置字符串列的默认值
- mercurial - 使用 vimdiff 时如何摆脱混乱的合并
- reactjs - 在 react-admin 中有条件地渲染 TextFields
- mongodb - MongoDb find 返回给定条件的字段值数组
- c - 无限循环如何进一步阻止早期代码的执行?
- html - 如何让两张照片在 HTML 中彼此相邻?