android - 为什么android在多次构建后显示错误的向量
问题描述
我已经在不同的应用程序中遇到这个问题很长时间了。我有分配给我的矢量绘图ImageView
。起初安装一切正常,每个 ImageView 都显示正确的可绘制对象,但在数十次构建和运行后,应用程序开始放错可绘制对象并将它们显示在错误的图像视图中,解决方案是完全卸载应用程序然后安装它。这在构建阶段有效,但我总是问我的问题,当用户收到十几个更新时会发生什么,这不会发生在他们身上吗?我没有使用pngs
,但因此这与andvectors
无关。multiple res folders
screen sizes
所以这是我的应用程序经过十几个构建
这是在全新安装之后
当您在无法丢失的应用程序上处理数据时,这真的很令人沮丧,我不得不丢失我保存的地址只是为了让图标正确显示。有没有人遇到过这个问题,他们是如何解决的?
解决方案
由于我有一个选择的数量,drawables
我最终只是在我的布局中添加了一个检查,比如
<data>
<import type="my.app.R"/>
</data>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/round_color_primary"
android:padding="@dimen/small_margin"
app:imageResource="@{address.type.value == 120 ? R.drawable.ic_home : (address.type.value == 121 ? R.drawable.ic_work : (address.type.value == 124 ? R.drawable.ic_star : R.drawable.ic_destination_outline))}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/white" />
推荐阅读
- here-api - HERE api 正在返回 PermissionError
- react-native - 嵌入自定义 React-Native 组件库
- c++ - 无法在 Linux Minut 中运行简单的 OpenGL 程序
- docker-compose - 执行脚本 docker-compose 失败
- r - (R) 将多个 txt 文件中的文本组合成一个连续的文本单元
- python - 当列表停止增加 Python 时返回索引
- spring - 使用 CamelSpringRunner 和 JavaConfig 模拟端点
- ios - 将动画添加到子视图时立即调用 CATransaction 完成块
- angular - 角度 6 中的替换()
- python - 问:如何在 Python 中将多个谓词传递给 SQL