我正在尝试使用 Canvas drawVertices 方法绘制四边形。每次使用此行都会崩溃:
private final float[] verts = new float[] {
0, 0, // 0 Top left
0, 800f, // 1 Bottom left
480f, 800f, // 2 Bottom right
480f,0f // 3 Top right
};
/* Order to draw the vertices */
private short[] indices = { 0, 1, 2, 0, 2, 3 };
private final int[] colors = new int[] {
Color.parseColor("#75AADB"),
Color.parseColor("#75AADB"),
Color.parseColor("#75AADB"),
Color.parseColor("#75AADB"),
Color.parseColor("#75AADB"),
Color.parseColor("#75AADB")
};
最后我调用实际的绘制方法:
paint.setStyle(Style.FILL); paint.setColor(Color.RED);
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, verts.length, verts, 0, null, 0, colors, 0, indices, 0, indices.length, paint);