【发布时间】:2018-04-06 07:34:09
【问题描述】:
在我的应用中,我使用的是这张图片:https://pixabay.com/sv/plus-l%C3%A4gga-till-%C3%B6ka-ikon-knappen-1270001/
但是,当我尝试在 Android Studio 中将其作为矢量资源导入时,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>
【问题讨论】:
-
如果没有看到 SVG,可能很难知道发生了什么。但我猜你不能发布它,因为它是一个商业产品。
-
“看到 SVG”是什么意思?你想要它的 XML 代码吗?
-
是的,我就是这个意思。
-
检查我编辑的问题
-
这就是 VectorDrawable XML。我指的是 SVG XML。
标签: android android-studio svg vector-graphics android-assets