我正在编写一个显示乐谱的小应用程序,当我绘制五线谱的线条时遇到了问题。同时,线条没有正确绘制。这是一张图片来说明我在说什么:
http://imageshack.us/photo/my-images/850/y1xk.png/
这是代码:
int x = canvas.getWidth();
int y = 0;
int x_margin = 40;
int y_margin = 60;
for (int i=1; i < 51; i++) {
canvas.drawLine(x_margin, y + y_margin, x - x_margin, y + y_margin, mLinePaint);
if (i % 5 == 0) {
if ((i % 10 != 0) && (tracks == 2)) {
canvas.drawLine(x_margin, y + y_margin, x_margin, y + y_margin + 40, mLinePaint);
canvas.drawLine(x - x_margin, y + y_margin, x - x_margin, y + y_margin + 40, mLinePaint);
y += 40;
}
else {
y += 60;
}
}
else {
canvas.drawLine(x_margin, y + y_margin, x_margin, y + y_margin + 15, mLinePaint);
canvas.drawLine(x - x_margin, y + y_margin, x - x_margin, y + y_margin + 15, mLinePaint);
y += 15;
}
}
有谁知道为什么会这样?
提前致谢。