我正在使用Android下载网站here中的一些向量。
将其放入如下所述的文件中:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/grey"
android:pathData="M22 3H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2zM8 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H2v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1zm3.85-4h1.64L21 16l-1.99 1.99c-1.31-.98-2.28-2.38-2.73-3.99-.18-.64-.28-1.31-.28-2s.1-1.36.28-2c.45-1.62 1.42-3.01 2.73-3.99L21 8l-1.51 2h-1.64c-.22.63-.35 1.3-.35 2s.13 1.37.35 2z"/>
</vector>
问题在于三星S4和HTC One(5.0.1和5.0.2)
11-05 13:37:34.380 uk.co.test.test W/System.err: Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v21/ic_grey_dark_absence_24dp.xml from drawable resource ID #0x7f020071
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3735)
at android.content.res.Resources.loadDrawable(Resources.java:3603)
at android.content.res.Resources.getDrawable(Resources.java:1852)
at android.content.Context.getDrawable(Context.java:408)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:177)
at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:170)
at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:53)
at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:74)
at uk.co.test.test.view.MenuItemView.init(MenuItemView.java:42)
at uk.co.test.test.view.MenuItemView.<init>(MenuItemView.java:22)
11-05 13:37:34.380 uk.co.test.test W/System.err: ... 32 more
11-05 13:37:34.380 uk.co.test.test W/System.err: Caused by: java.lang.NumberFormatException: Invalid float: "1.1.9"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:160)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at android.util.PathParser.getFloats(PathParser.java:178)
at android.util.PathParser.createNodesFromPathData(PathParser.java:59)
at android.graphics.drawable.VectorDrawable$VFullPath.updateStateFromTypedArray(VectorDrawable.java:1439)
at android.graphics.drawable.VectorDrawable$VFullPath.inflate(VectorDrawable.java:1421)
at android.graphics.drawable.VectorDrawable.inflateInternal(VectorDrawable.java:542)
at android.graphics.drawable.VectorDrawable.inflate(VectorDrawable.java:458)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1150)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1063)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3719)
然而,我发现,这是由任何值包含两个“。”的向量引起的,例如1.1.9。如果您将上面的矢量更改为购物篮图标:
<path
android:fillColor="@color/grey"
android:pathData="M17.21,9l-4.38,-6.56c-0.19,-0.28 -0.51,-0.42 -0.83,-0.42 -0.32,0 -0.64,0.14 -0.83,0.43L6.79,9H2c-0.55,0 -1,0.45 -1,1 0,0.09 0.01,0.18 0.04,0.27l2.54,9.27c0.23,0.84 1,1.46 1.92,1.46h13c0.92,0 1.69,-0.62 1.93,-1.46l2.54,-9.27L23,10c0,-0.55 -0.45,-1 -1,-1h-4.79zM9,9l3,-4.4L15,9H9zm3,8c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
一切正常。
我在code.google.com/p/android上找不到报告的错误,我想知道除了“更改所有向量”之外还有其他工作吗?
答案 0 :(得分:3)
在Vector Asset Studio中创建的相同图标似乎没有遇到此问题。所以我想解决方案是始终使用Vector Asset Studio来创建矢量xml
文件。