根据Canvas.drawVertices Javadoc,如果texs参数也是null,则传递null作为画图是有效的。
如果
数组为非空,则指定要使用的着色器。
当使用drawVertices方法调用null进行画图时,这将导致一个空指针异常。
发布于 2012-04-26 21:06:22
因为在内部它会调用
nativeDrawVertices(mNativeCanvas, mode.nativeInt, vertexCount, verts,
vertOffset, texs, texOffset, colors, colorOffset,
indices, indexOffset, indexCount, paint.mNativePaint);如果画图为null,paint.mNativePaint将导致NullPointerException。文档忘记告诉您,在这里,油漆不能为空:)
另外,绘制没有画图的顶点似乎是不符合逻辑的,因为画图定义了行类型等,而文档没有声明paint is optional。
https://stackoverflow.com/questions/10341363
复制相似问题