-2
for (int x = 0; x < canvas.getHeight(); x += LINE_SPACING) {
canvas.drawLine(0, 0, 0, canvas.getWidth(), paint);

此代码制作一条垂直线。我怎样才能使这个水平

4

2 回答 2

0

您将 x 和 y 的概念颠倒过来:

canvas.drawLine(0, 0, canvas.getWidth(), 0, paint);

此外,目前还不清楚为什么你有这个循环。如果你想画一堆水平线,它应该是这样的:

for (int y = 0; y < canvas.getHeight(); y += LINE_SPACING) {
    canvas.drawLine(0, y, canvas.getWidth(), y, paint);
}
于 2013-03-28T18:17:00.253 回答
0
for (int y = 0; y < canvas.getWidth(); y += LINE_SPACING) {
canvas.drawLine(0, 0, canvas.getHeight(), 0, paint);
于 2013-03-28T18:17:53.013 回答