我希望它在屏幕中央显示为 7 x 7 方形网格,但是正如您在我当前的代码中看到的那样,垂直线位于正确的位置,但水平线不在。我相信这是一个简单的修复,任何帮助将不胜感激 -
public class GameGrid extends View {
Paint black = new Paint();
public GameGrid(Context context) {
super(context);
black.setColor(Color.BLACK);
black.setStrokeWidth(8);
}
@Override
public void onDraw(Canvas canvas) {
float startX;
float stopX;
float startY;
float stopY;
int width = canvas.getWidth();
int height = canvas.getHeight();
int gridSize = 7;
int gridSpacing = width / gridSize;
//Vertical Grid-lines
for (int i = 0; i < gridSize; i++) {
startX = width / 2 - height / 2;
stopX = …Run Code Online (Sandbox Code Playgroud)