【发布时间】:2021-01-06 19:02:51
【问题描述】:
我正在尝试导入从Ipe 导出的 SVG 文件。除了我在 Ipe 中添加文本的文件之外,导出的文件都可以正常工作。
我从 Android Studio 收到的警告是 The image may be incomplete due to encountered issues,当我检查问题时,它只是 ERROR @ line X: <symbol> is not supported 的行。 Android Studio 似乎不支持 SVG 文件中的 <symbol>。
我的问题是,是否有一个实用程序可以让我将此 SVG 文件转换为 SVG 文件或直接转换为 Android Studio 支持的 XML 文件?如果没有,我将如何手动做这种事情? Ipe 也支持导出为 EPS,但是在尝试将其转换回 SVG 时,我使用的转换器仍然使用 <symbol>。
为了展示 SVG 文件的外观而不是用数百行向整个问题发送垃圾邮件,我创建了一个包含 1 的简单文本框并将其导出为 SVG 文件以作为示例:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="7pt" height="9pt" viewBox="0 0 7 9" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d=""/>
</symbol>
<symbol overflow="visible" id="glyph0-1">
<path style="stroke:none;" d="M 2.9375 -6.375 C 2.9375 -6.625 2.9375 -6.640625 2.703125 -6.640625 C 2.078125 -6 1.203125 -6 0.890625 -6 L 0.890625 -5.6875 C 1.09375 -5.6875 1.671875 -5.6875 2.1875 -5.953125 L 2.1875 -0.78125 C 2.1875 -0.421875 2.15625 -0.3125 1.265625 -0.3125 L 0.953125 -0.3125 L 0.953125 0 C 1.296875 -0.03125 2.15625 -0.03125 2.5625 -0.03125 C 2.953125 -0.03125 3.828125 -0.03125 4.171875 0 L 4.171875 -0.3125 L 3.859375 -0.3125 C 2.953125 -0.3125 2.9375 -0.421875 2.9375 -0.78125 Z M 2.9375 -6.375 "/>
</symbol>
</g>
</defs>
<g id="surface1894">
<g style="fill:rgb(0%,0%,0%);fill-opacity:1;">
<use xlink:href="#glyph0-1" x="1" y="8"/>
</g>
</g>
</svg>
【问题讨论】:
-
如果不支持符号,在这种情况下,您可以使用组来代替,因为您没有使用元素的宽度和高度。您也可以尝试使用嵌套的 svg 代替符号
标签: android android-studio android-layout svg