for (int x = 0; x < canvas.getHeight(); x += LINE_SPACING) {
canvas.drawLine(0, 0, 0, canvas.getWidth(), paint);
此代码生成一条垂直线。我怎样才能使这个水平
答案 0 :(得分: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);
}
答案 1 :(得分:0)
for (int y = 0; y < canvas.getWidth(); y += LINE_SPACING) {
canvas.drawLine(0, 0, canvas.getHeight(), 0, paint);