gpt4 book ai didi

Android Studio 矢量资源失真

转载 作者:行者123 更新时间:2023-12-04 23:45:26 30 4
gpt4 key购买 nike

当我在编辑器上导入矢量 svg 文件时,图标看起来很正常,但是当我调试图标时,图标会变形,svg 中没有使用任何转换!我正在使用最新的 Android Studio 4.0 Canary 9 ,因为我使用的是锐龙 5 处理器。

enter image description here

这是我在 Android Studio 中导入的原始 svg 文件。

<svg id="brush" 
xmlns="http://www.w3.org/2000/svg" width="27.17" height="27.17" viewBox="0 0 27.17 27.17">
<defs>
<style>.cls-1{fill:#2ca0d4;}</style>
</defs>
<path id="Path_4" data-name="Path 4" class="cls-1" d="M9.58,18.19a4.87,4.87,0,0,0-5.3-1,4.87,4.87,0,0,0-2.86,4.39,10.27,10.27,0,0,1-.72,4.36L0,27l1.31.09c.32,0,.66,0,1,0,2.56,0,5.68-.64,7.36-2.19A4.94,4.94,0,0,0,9.58,18.19Z" />
<path id="Path_5" data-name="Path 5" class="cls-1" d="M13,14.81A9.32,9.32,0,0,0,10.38,13c-.8.83-1.59,1.67-2.35,2.51a6.08,6.08,0,0,1,2.68,1.57,6.26,6.26,0,0,1,1.6,2.75c.83-.75,1.66-1.52,2.5-2.33A8.46,8.46,0,0,0,13,14.81Z" />
<path id="Path_6" data-name="Path 6" class="cls-1" d="M26.82.35c-.6-.6-1.58-.87-6.34,2.83a109.1,109.1,0,0,0-8.86,8.52l-.06.06h0l0,0a11,11,0,0,1,2.55,1.89A10,10,0,0,1,16,16.32l0,0h0l.09-.09A97.7,97.7,0,0,0,24,6.7C27.69,1.93,27.41,1,26.82.35Z" />
</svg>

即使我将 wrap_content 用于第二面,它仍然会失真
android:layout_width="500dp"
android:layout_height="wrap_content"

当我从剪贴画中导入图标时,在 Android Studio 中预先制作的图标没有问题。我导入的 svg 文件有什么问题?
enter image description here

最佳答案

我设法使用不同的矢量(SVG)编辑工具来修复它。就我而言,我使用了免费程序 Microsoft Expression Design。
所以问题是一些更高级的程序,如 Illustrator、Adobe XD 使用 SVG 2.0 中支持的新方法缩短导出的数据。或更高版本。所以解决方案是使用一些工具,如 Expression Design,将文件转换为 SVG 1.1 ,它总是在 Android Studio 中正确导入。
这是 SVG 文件的代码,但通过 Expression Design 导出。

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="36.1963" height="36.095" viewBox="0 0 36.20 36.10" enable-background="new 0 0 36.20 36.10" xml:space="preserve">
<path fill="#2CA0D4" fill-opacity="1" stroke-width="1.33333" stroke-linejoin="miter" d="M 12.7734,24.2283C 10.9014,22.4009 8.11572,21.8754 5.70673,22.895C 3.40485,23.9378 1.91718,26.2214 1.89331,28.7483C 1.99896,30.7327 1.67139,32.7165 0.93335,34.5616L 0,35.9749L 1.74664,36.095C 2.17334,36.095 2.62665,36.095 3.08002,36.095C 6.49335,36.095 10.6533,35.2416 12.8933,33.175C 15.1959,30.619 15.1436,26.7216 12.7734,24.2283 Z "/>
<path fill="#2CA0D4" fill-opacity="1" stroke-width="1.33333" stroke-linejoin="miter" d="M 17.3333,19.7216C 16.316,18.7227 15.1343,17.9064 13.84,17.3083C 12.7734,18.415 11.72,19.535 10.7067,20.655C 12.0589,21.0316 13.2902,21.753 14.28,22.7483C 15.2951,23.7664 16.0298,25.0294 16.4133,26.415C 17.52,25.415 18.6266,24.3883 19.7466,23.3083C 19.1809,21.9683 18.3615,20.7504 17.3333,19.7216 Z "/>
<path fill="#2CA0D4" fill-opacity="1" stroke-width="1.33333" stroke-linejoin="miter" d="M 35.76,0.441589C 34.96,-0.358398 33.6533,-0.718384 27.3066,4.21497C 23.1585,7.77655 19.2145,11.5693 15.4933,15.575L 15.4133,15.655L 15.4133,15.655C 16.6625,16.3262 17.8077,17.175 18.8133,18.175C 19.8431,19.2152 20.6944,20.418 21.3333,21.7349L 21.4534,21.6149C 25.2341,17.6067 28.7567,13.3627 32,8.90826C 36.92,2.54828 36.5466,1.30829 35.76,0.441589 Z "/>
</svg>

关于Android Studio 矢量资源失真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60417652/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com