title: How to align center a bitmap?
body: <p>i want my bitmap in the center of my screen..i m trying it that way but its not working...</p>
  
  <pre><code>Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.compass);
  
              int w = canvas.getWidth();
              int h = canvas.getHeight();
  
              int bw=myBitmap.getWidth();
              int bh=myBitmap.getHeight();
  
              int cx = w / 2;
              int cy = h / 2;
  
              Display d = getWindowManager().getDefaultDisplay();
              int x = d.getWidth();
              int y = d.getHeight();
              int dx = x / 2;
              int dw = y /2;
              canvas.translate(cx, cy);    
              if (mValues != null) {
                  canvas.rotate(-mValues[0]);
              }  
  
              int centreX = (x  - bw) /2;
  
                  int centreY = (cy - bh) /2;  
              //canvas.drawPath(mPath, mPaint);
              canvas.drawBitmap(myBitmap, centreX,centreY, null);
  </code></pre>