2013-09-16 62 views
0

我想繪製一個使用Canvas drawVertices方法quadriliteral。 它崩潰這一行每次:android 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); 
+0

崩潰時logcat輸出是什麼? –

回答

1

遲了,但試着在您的顏色數組中添加兩個Color.parseColor("#75AADB")verts.length必須等於colors.length