【发布时间】:2021-11-03 14:39:02
【问题描述】:
我的项目中有很多矢量绘图。所有这些都被用作一个填充颜色作为主题属性。在这种情况下,资源管理器预览不会显示,直到通过工具将某些颜色设置为可绘制对象。
如图所示,ic_drag 是红色的,因为 tools:fillColor="#ff0000"。但是 ic_arrow_back_on_primary 预览是空的。
ic_drag:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?banan"
tools:fillColor="#ff0000"
android:pathData="M20,9H4v2h16V9zM4,15h16v-2H4V15z" />
</vector>
ic_arrow_back_on_primary:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?colorOnPrimary"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z" />
</vector>
如果打开可绘制对象的编辑器,则会显示此可绘制对象的预览。使用哪种方式无关紧要:属性或直接颜色。
有没有办法强制资源管理器显示预览而不添加“工具”属性?
【问题讨论】:
标签: android android-studio android-theme android-vectordrawable