title: Android canvas.translate()
body: <p>I am using canvas.translate to change the coodinates of my canvas so that the viewport changes</p>
  
  <p>my code :</p>
  
  <pre><code>public class draw extends View {
      View v;
      Paint paint;
  
      int width;
      int height;
  
      int view_x;
      int view_y;
  
      static final int MAX_GAME_SPEED = 25;
      static int fps;
  
      public draw(Context context) {
          super(context);
  
          // tb.loadimg();
  
          Thread myThread = new Thread(new UpdateThread());
          myThread.start();
      }
  
      @Override
      protected void onDraw(Canvas c) {
          super.onDraw(c);
          paint = new Paint(); // Paint paint = new Paint();
          paint.setStyle(Paint.Style.FILL);
  
          // get screen size
          WindowManager wm = (WindowManager) this.getContext().getSystemService(
                  Context.WINDOW_SERVICE);
          Display display = wm.getDefaultDisplay();
  
          width = display.getWidth(); // deprecated
          height = display.getHeight(); // deprecated
  
          // make the entire canvas white
          paint.setColor(Color.WHITE);
          c.drawPaint(paint);
  
          if (tb.dirt != null &amp;&amp; tb.stone != null &amp;&amp; tb.sand != null
                  &amp;&amp; tb.gold != null &amp;&amp; tb.iron != null &amp;&amp; tb.coal != null
                  &amp;&amp; tb.kies != null &amp;&amp; tb.diamond != null &amp;&amp; tb.redstone != null
                  &amp;&amp; tb.lava != null &amp;&amp; tb.azur != null &amp;&amp; tb.water != null) {
              c.drawBitmap(tb.dirt, 0, 0, paint);
              c.drawBitmap(tb.stone, 0, 50, paint);
              c.drawBitmap(tb.sand, 0, 100, paint);
              c.drawBitmap(tb.gold, 0, 150, paint);
              c.drawBitmap(tb.iron, 50, 0, paint);
              c.drawBitmap(tb.coal, 50, 50, paint);
              c.drawBitmap(tb.kies, 50, 100, paint);
              c.drawBitmap(tb.diamond, 50, 150, paint);
              c.drawBitmap(tb.redstone, 100, 0, paint);
              c.drawBitmap(tb.lava, 100, 50, paint);
              c.drawBitmap(tb.azur, 100, 100, paint);
              c.drawBitmap(tb.water, 100, 150, paint);
  
          }
          if (tb.map == null) {
  
          }
          view_x = 100;
          view_y = 100;
  
          c.translate(0, -4);
  
      }
  
      public Handler updateHandler = new Handler() {
          /** Gets called on every message that is received */
          // @Override
          public void handleMessage(Message msg) {
  
              invalidate();
              super.handleMessage(msg);
          }
      };
  
      public class UpdateThread implements Runnable {
  
          @Override
          public void run() {
              while (true) { // Game Loop
  
                  long startTime = System.currentTimeMillis();
                  draw.this.updateHandler.sendEmptyMessage(0); // veranlassen,
                                                                  // dass paint()
                                                                  // erneut
                                                                  // aufgerufen
                                                                  // werden soll
                  // for (int i=0; i&lt;999999; i++); //Bremse
  
                  Thread.yield();
                  long executionTime = System.currentTimeMillis() - startTime;
  
                  if (executionTime &lt; MAX_GAME_SPEED) {
                      try {
                          Thread.sleep(MAX_GAME_SPEED - (int) executionTime);
                      } catch (InterruptedException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                      fps = 1000 / MAX_GAME_SPEED;
                  } else
                      fps = (int) (1000 / executionTime);
  
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>but simply nothing happens
  I have seen many online examples but I just don't get throug my problem -.-</p>