Draw dots in canvas like matrix android
<p>I have a application where i want to generate dots like 2 x 2, 3 x 3 and 4 x 4 dynamically
<img src="http://i.stack.imgur.com/yOg46.gif" alt="like this"></p>

<p>now i am drawing dot matrix without dynamic using code as follows :</p>

<pre><code>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&lt;1;wid+=2/8)
                {
                for(ht=5/16;ht&lt;3/4;ht+=1/8)
                {
                    canvas.drawCircle(wid,ht,3, mPaint);
                }
                }//this for loop crash the application 
            }
</code></pre>

<p>and i need a formula to generate dots in my center of canvas please help me
The code mentioned above is added in onDraw() method Thanks in advance</p>
