title: collision with wall isn't accurate
body: <p>So I'm trying to make a ball hit the wall and bounce off it just like pong game. but for some reason when ball thinks the canvas is smaller that it actually is.
  here is my onDraw code:</p>
  
  <pre><code>        canvasWidth = canvas.getWidth();
          canvasHeight = canvas.getHeight();
          if (flag) {
              x = (int) canvasWidth;
              y = (int) canvasHeight;
          }
      else
          {
              if (goingRight)
              x=x+5;
              else
              x=x-5;
              if (goingDown)
              y=y+5;
              else
                  y=y-5;
          }
          canvas.drawBitmap(ball,x/2,y/2,null);
          if (x&gt;canvasWidth)
              goingRight=false;
          else if (x&lt;0)
          goingRight=true;
      if (y&gt;canvasHeight)
          goingDown=false;
      else if (y&lt;0)
      {
          goingDown=true;
      }
  
  
  
  
      flag=false;
  </code></pre>
  
  <p>Couldn't find a fix for it. anyone knows what is the problem?</p>