title: Drawing text on canvas appropriately
body: <p>I am try to draw text and bitmap images in my app. I would like the text to be drawn above the bitmap icons but am having difficulties in achieving that.</p>
  
  <p>How do i modify or change my code so it displays at the top of each icon <img src="https://i.stack.imgur.com/HH3uf.jpg" alt="Screen shot of the app notice the text is behind the icon"></p>
  
  <p>my code:</p>
  
  <pre><code>protected void onDraw(Canvas canvas) {
      // TODO Auto-generated method stub
      super.onDraw(canvas);
  
  
  
      xCanvas = canvas.getWidth();
      yCanvas = canvas.getHeight();
  
  
  
      Paint textPaint2 = new Paint();
      textPaint2.setStyle(Paint.Style.FILL_AND_STROKE);
      textPaint2.setAntiAlias(true);
      textPaint2.setColor(Color.WHITE);
      textPaint2.setTextSize(30);
      textPaint2.setTextAlign(Align.CENTER);
  
  
      destination = new Location("manual");
  
      for (int j = 0; j &lt; placesListItems.size(); j++){
          song = placesListItems.get(j);
  
          this.lat = myLat.get(j);
          this.lng = myLng.get(j);
          this.name=song.get(KEY_NAME);
  
          try {
              this.icon = ICON.get(j);
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          //  Log.d("the latitude",(String.valueOf(this.lat)));
          //  Log.d("the longitude",(String.valueOf(this.lng)));
          // Double.parseDouble(song.get(KEY_LNG));
  
  
  
          destination.setLatitude(this.lat);
          destination.setLongitude(this.lng);
  
  
  
  
          //Log.d("Place name",name );
  
          this.location.distanceTo(destination);
  
          // compute rotation matrix
          float rotation[] = new float[9];
          float identity[] = new float[9];
          if (lastAccelerometer != null &amp;&amp; lastCompass != null) {
              boolean gotRotation = SensorManager.getRotationMatrix(rotation,
                      identity, lastAccelerometer, lastCompass);
              if (gotRotation) {
                  float cameraRotation[] = new float[9];
                  // remap such that the camera is pointing straight down the
                  // Y
                  // axis
                  SensorManager.remapCoordinateSystem(rotation,
                          SensorManager.AXIS_X, SensorManager.AXIS_Z,
                          cameraRotation);
  
                  // orientation vector
                  orientation = new float[3];
                  SensorManager.getOrientation(cameraRotation, orientation);
  
                  canvas.save();
  
                  // Translate, but normalize for the FOV of the camera --
                  // basically, pixels per degree, times degrees == pixels
                  float dx = (float) ((canvas.getWidth() / horizontalFOV) * (Math
                          .toDegrees(orientation[0]) - this.location
                          .bearingTo(destination)));
                  float dy = (float) ((canvas.getHeight() / verticalFOV) * Math
                          .toDegrees(orientation[1]));
  
  
                  // wait to translate the dx so the horizon doesn't get
                  // pushed off
                  canvas.translate(0.0f, 0.0f - dy);
  
  
                  // now translate the dx
                  canvas.translate(0.0f - dx, 0.0f);
  
                  canvas.drawText((truncate(this.name,10).concat("...")), canvas.getWidth()/2 - 50, canvas.getHeight() / 2 - 100,
                          textPaint2);
  
                  canvas.drawBitmap(icon, canvas.getWidth()/2 - icon.getWidth()/2, canvas.getHeight()/2 - icon.getHeight()/2, null);
  
                  canvas.restore();
              }
          }
  
      }
  
  
  }
  </code></pre>