title: Wrap text in button gracefully at whitespace
body: <p>I have an android application in which a user can create what is basically a macro and label that macro with some text. I then create a button for them with their descriptive text.  The button is a custom view extending <code>Button</code>.  In the constructor I set the layout as follows:</p>
  
  <pre><code>this.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  </code></pre>
  
  <p>These buttons are then placed within a <code>GridView</code>.  Functionally, it's working as intended but I'm running into a layout issue.</p>
  
  <p>If the text is too long, it will break and wrap to the next line, thus increasing the height of the button while maintaining a constant width.  The problem is in how the text wraps, it will break in the middle of a word, instead of gracefully wrapping at whitespace.  For instance the test "Perform an Action" will render as</p>
  
  <pre><code>Perform an Ac
      tion
  </code></pre>
  
  <p>Ideally, I'd like to wrap gracefully at whitespace instead of breaking words across lines. I suppose I could do this by checking the length of the text and the font against the width of the button and then doing some fancy insertion of newlines myself, but that gives me traumatic flashbacks to making win32 UIs.  Is there a better way?</p>