- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用中,我使用了这张图片:https://pixabay.com/sv/plus-l%C3%A4gga-till-%C3%B6ka-ikon-knappen-1270001/
但是,当我尝试在 Android Studio 中将其作为 Vector Asset 导入时,Asset Studio 会在左右边缘对其进行切割,使其不再是一个完整的圆。为什么会这样?我该如何解决?我必须修改 svg,还是可以更改 Android Studio 中的某些设置?
这是 SVG 的 XML 代码:
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 35.876 35.876" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-1.5317 -1015.4)">
<circle transform="matrix(-.5 -.86603 .86603 -.5 0 0)" cx="-904.64" cy="-499.82" r="16.205" fill="none" stroke="#ff5e00" stroke-width="3.4773"/>
<flowRoot fill="#000000" font-family="Sans" font-size="46.364px" letter-spacing="0px" word-spacing="0px" style="line-height:125%" xml:space="preserve"><flowRegion><rect x="-3.0977" y="-173.71" width="144.82" height="50.201"/></flowRegion><flowPara/></flowRoot>
<rect transform="rotate(90)" x="1032" y="-27.666" width="2.7808" height="16.392" rx=".20089" ry=".20089" fill="#ff5e00"/>
</g>
</svg>
下面是 Vector Drawable 的 XML 格式:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="35dp"
android:height="35dp"
android:viewportWidth="35.876"
android:viewportHeight="35.876">
<path
android:pathData="M17.93,17.96m8.1,14.03a16.21,16.21 83.34,1 1,-16.2 -28.07a16.21,16.21 83.34,1 1,16.2 28.07"
android:strokeColor="#ff5e00"
android:fillColor="#00000000"
android:strokeWidth="3.4773"/>
<path
android:fillColor="#FF000000"
android:pathData="M-3.99,-1020.96h124.94v43.31h-124.94z"/>
<path
android:pathData="M16.75,9.8L19.13,9.8A0.2,0.2 0,0 1,19.33 10L19.33,25.99A0.2,0.2 0,0 1,19.13 26.19L16.75,26.19A0.2,0.2 0,0 1,16.55 25.99L16.55,10A0.2,0.2 0,0 1,16.75 9.8z"
android:fillColor="#ff5e00"/>
<path
android:pathData="M26.13,16.8L26.13,19.18A0.2,0.2 101.89,0 1,25.93 19.38L9.94,19.38A0.2,0.2 102.72,0 1,9.74 19.18L9.74,16.8A0.2,0.2 102.72,0 1,9.94 16.6L25.93,16.6A0.2,0.2 101.89,0 1,26.13 16.8z"
android:fillColor="#ff5e00"/>
</vector>
最佳答案
这似乎是由于 Android Studio SVG 导入功能中的一个错误。它没有转换 <circle>
SVG 中的正确元素。
查看下面的示例。 SVG 中的原始元素为绿色。我已将路径元素从 VectorDrawable 转换回 SVG 路径,并将它们覆盖在原始 SVG 上。您可以看到红色的圆圈路径(来自 VectorDrawable)与原始 SVG 不匹配。
<svg version="1.1" viewBox="0 0 35.876 35.876" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-1.5317 -1015.4)">
<circle transform="matrix(-.5 -.86603 .86603 -.5 0 0)" cx="-904.64" cy="-499.82" r="16.205" fill="none" stroke="#00ff00" stroke-width="3.4773"/>
<rect transform="rotate(90)" x="1032" y="-27.666" width="2.7808" height="16.392" rx=".20089" ry=".20089" fill="#00ff00"/>
</g>
<g id="converted back from VectorDrawable">
<path d="M17.93,17.96m8.1,14.03a16.21,16.21 83.34,1 1,-16.2 -28.07a16.21,16.21 83.34,1 1,16.2 28.07"
fill="none" stroke="red" stroke-width="3.4773" stroke-opacity="0.3"/>
<path d="M26.13,16.8L26.13,19.18A0.2,0.2 101.89,0 1,25.93 19.38L9.94,19.38A0.2,0.2 102.72,0 1,9.74 19.18L9.74,16.8A0.2,0.2 102.72,0 1,9.94 16.6L25.93,16.6A0.2,0.2 101.89,0 1,26.13 16.8z"
fill="red" fill-opacity="0.5"/>
</g>
</svg>
原先的SVG图标设计的很乱,可能会加剧这个问题。它充满了带有奇数小数和奇怪变换的坐标。
我可以为您修复 SVG,但我想您有多个图标可能会出现相同的错误。
我打算建议您尝试其中一种替代在线转换器。但我只是尝试了它们,也没有正确处理您的 SVG。也许您可以尝试不同的图标集,或者尝试在矢量编辑器(如 Inkscape)中重新创建这些图标。
关于android - 为什么 Android Asset Studio 会剪切我的矢量图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46928557/
我经常使用 SSMS 查询数据和构建数据集,我的 IT 部门负责数据库管理。 最近我发现了 Azure Data Studio,我喜欢: 智能感知 源代码控制(例如使用 Git) 来自社区的扩展 SQ
我想根据我使用的 visual studio 版本编译不同的东西,比如 #if VISUAL_STUDIO_VERSION > 2015 eventH?.Invoke(this, EventArgs.
我们的开发团队计划从 visual studio 2005 升级到 visual studio 2010 -- 跳过 visual studio 2008。 大部分项目是VB ASP.NET项目,使用
我的Visual Studio 2015无法构建2010平台工具集。它说: The build tools for Visual Studio 2010 (v100) cannot be found.
我目前正在使用 Visual Studio 2015 来编程 ASP.NET Core 应用程序。我对安装 Visual Studio 2017 有以下疑问: 什么被认为是最佳实践和/或最干净的方法?
尝试从扩展和更新获取 Visual Studio 扩展时,出现以下错误:- 向 visualstudiogallery.msdn.microsoft.com/Services/VStudio/Exte
这个问题在这里已经有了答案: Can Visual Studio Code and VS 2012 be installed on same computer? (1 个回答) 关闭去年。 在安装了
作为标准安装的一部分,Visual Studio Code 带有一个名为“Monokai Dimmed”的颜色主题。 有没有办法将它移植到 Visual Studio 2015?我检查了社区主题( h
我想开始编程 CUDA。 我已经安装了 Visual Studio 2010 Express。 我还安装了 nVidia nSight Visual Studio。 而且我具备所有常见的先决条件(Ne
Visual Studio Community Edition是否可以使用Visual Studio Online帐户上的存储库? 我一直为包含在Online帐户中的Visual Studio Onl
我有一个我一直在开发的应用程序,但在 android studio 上遇到了问题。当我点击“build->run”然后选择我的设备时,应用程序永远不会在我的手机上运行(并且自动出现的android-s
我正在使用Visual Studio2010。我面临的一个问题是,当我创建一个新的Web项目时,Visual Studio将创建该项目,并且不会在解决方案资源管理器中显示其解决方案。 另一件事是,我想
我通读了这里的许多帖子,却找不到一个有效的明确答案。因此,在花了一些时间使它生效之后,我认为应该发布它。 问题:发布配置文件将建立在服务器上,但不会发布。 解: 确保已安装Microsoft Wind
我正在尝试使用Visual Studio 2012构建针对.NET 3.5的C++ CLI应用程序。 通过安装Visual Studio 2008,并指定v90平台工具集,我已经在一台机器上进行了这项
我在 Microsoft Visual Studios 2013 中有一个项目,我想在 Microsoft Visual Studios 2010 中打开它。有什么简单的方法吗?还是我必须在2010年
我想知道,如果我发送一个解决方案文件夹(它是用 visual studio C# 编写的),您可以在 visual studio for mac 中打开解决方案吗? 在visual studio 20
有没有办法在 Visual Studio Code 和 Visual Studio 中设置相同的快捷方式(而不必每次都手动更改它们)? 例如,我在 Visual Studio Code 中经常使用 A
我刚开始了解 Visual Studio Code。我想知道,我可以将 Visual Studio 替换为所有 .NET 开发相关的工作吗? 我可以节省 Visual Studio 许可的成本吗? V
我安装了具有有效许可证(Visual Studio 订阅)的 Visual Studio 2019 企业版(VS 2019 16.1.4),它运行良好。 突然之间,当我尝试打开项目或项目中的任何文件时
我一直在使用 Compass 编译 Windows 环境中的 sass 文件,无论是在命令行上还是使用 Compass-app 来查看目录。 我刚刚开始使用 Visual Studio(专业版 201
我是一名优秀的程序员,十分优秀!