title: Android - Custom view and canvas size - Chicken and egg prob
body: <p>I'm designing a custom view that displays an expression (You can think about it as a complex TextView).</p>
  
  <p>As the expression grows, I want my custom view to expand to accommodate it (Just like a wrap_content TextView).</p>
  
  <p>when the content of the view is changed I buffer a canvas that is later drawn by <code>onDraw()</code></p>
  
  <p>The buffering is done using</p>
  
  <pre><code>Bitmap canvasBitmap = Bitmap.createBitmap(width, height , Config.RGB);
  Canvas canvas = new Canvas(canvasBitmap);
  canvas.drawText(pos,text, paint);
  pos += paint.MesureText(text);
  // and so on...
  ...
  ...
  </code></pre>
  
  <p>Only at the end of this process I know what width of canvas I really need - The value of <code>pos</code>, but I need it prior to it's calculation in the <code>Bitmap.createBitmap()</code>.
  Is there a way to create a canvas without specifies it's boundaries and then cut it to the right size? I don't want to do the process first to find out which width I need and then run it again to create an a view in the right size.</p>
  
  <p>Any suggestions would be appreciated. </p>