title: onMeasure(): wrap_content, how do I know the size to wrap?
body: <p>I have made a custom View with <code>onDraw()</code> overridden that draws a bitmap on the canvas. When I specify that I want it wrap_content in the layout file it still fills up the entire screen. <code>onMeasure()</code> says this:</p>
  
  <blockquote>
    <p>The base class implementation of measure defaults to the background size, unless a larger size is allowed by the <code>MeasureSpec</code>. Subclasses should override onMeasure(int, int) to provide better measurements of their content.</p>
  </blockquote>
  
  <p>Ok cool so I know I need to override <code>onMeasure()</code> and work with <code>MeasureSpec</code>. According to <a href="https://stackoverflow.com/questions/12266899/onmeasure-custom-view-explanation">this answer</a></p>
  
  <blockquote>
    <p>UNSPECIFIED means the layout_width or layout_height value was set to wrap_content. You can be whatever size you would like.</p>
  </blockquote>
  
  <p>Now I get to my problem, how do I at <code>onMeasure()</code> measure my bitmap that is not created yet and  measure/wrap it? I know the other Android views MUST do something because they do not block out the entire screen if set to wrap_content. Thanks in advance!</p>