我有一个应用程序,我想动态生成像 2 x 2、3 x 3 和 4 x 4 这样的点
现在我正在使用以下代码绘制没有动态的点阵:
if(test.equals("galmenu2"))
{
canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);
canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
}
else if(test.equals("galmenu3"))
{
canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(wid/2,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(wid/4,ht/2,3, mPaint);
canvas.drawCircle(wid/2,ht/2,3, mPaint);
canvas.drawCircle(3*wid/4,ht/2,3, mPaint);
canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
canvas.drawCircle(wid/2,5*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);
}
else if(test.equals("galmenu4"))
{
for(wid=1/8;wid<1;wid+=2/8)
{
for(ht=5/16;ht<3/4;ht+=1/8)
{
canvas.drawCircle(wid,ht,3, mPaint);
}
}//this for loop crash the application
}
我需要一个公式来在我的画布中心生成点请帮助我上面提到的代码添加在 onDraw() 方法中提前谢谢