title: Tiling a Bitmap on a Canvas
body: <p>I would like to create a 'graph paper' look to the Bitmap I am drawing via a Canvas, and trying to figure out the best way to do this.</p>
  
  <p>I can't pass a source Bitmap containing the graph paper background to the Canvas constructor, as I am getting the Canvas in a SurfaceView via the .lockCanvas() call.</p>
  
  <p>Some solutions I've tried:</p>
  
  <ul>
  <li><p>I've tried implementing <a href="https://stackoverflow.com/questions/1311042/android-tile-bitmap/4575738#4575738">this solution</a> in my SurfaceView's Thread.run(), but the issue I believe is when the BitmapDrawable is converted to a Bitmap... it loses the tiling properties.</p>
  
  <p>canvas = mSurfaceHolder.lockCanvas(null);
  BitmapDrawable TileMe = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.editor_graph));
  TileMe.setTileModeX(Shader.TileMode.REPEAT);
  TileMe.setTileModeY(Shader.TileMode.REPEAT);</p>
  
  <p>Bitmap b = TileMe.getBitmap();
  canvas.drawBitmap(b, 0, 0, null);</p></li>
  <li><p>If I use the <a href="http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.RectF,%20android.graphics.Paint%29" rel="nofollow noreferrer">Canvas.drawBitmap method that takes a destination RectF as a parameter</a>, it looks like the bitmap will be tiled to fill the RectF... but how do I declare a RectF reliably that fills the entire view area? </p></li>
  <li>Setting the Activities background to the desired graph paper look also doesn't work, as the bitmap/canvas layout is opaque and blocks that from being seen.</li>
  </ul>
  
  <p>Any ideas how to achieve this?</p>