title: Set individual lines of TextView to different width
body: <p>I'm trying to setup a TextView that contains two lines of text, the second line being shorter than the first one.</p>
  
  <p>Is there a way to set up TextView's Layout instance (acquired via TextView.getLayout()) to truncate the second line, or is there another way that I'm not aware of?</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>There were misinterpretations of my intentions: I'm trying to set a textview layouted in a way, that i can set arbitrary text and depending on the length the following happens:
  If the text is long enough to start a second line, make the first line as wide as the textview's content width is, but the second line should be shorter, for example half as wide. But there should be a second line, if text is long enough.</p>
  
  <p>I checked out abstract class Layout and it's subclasses, there is a function </p>
  
  <pre><code>public int getLineEnd(int line)
  </code></pre>
  
  <p>that returns the position of the last character for a line. A way could be to set the text, then check out how wide the second line is layouted and then change the text to a shorter version. Anyways, that seems to be a hacky way, which could be made much cleaner and more stable, if I could set a Layout instance myself (via a setter method, such as getter</p>
  
  <pre><code>TextView.getLayout().
  </code></pre>
  
  <p>Has anyone set a custom Layout to a subclass of Textview?</p>
  
  <p><strong>EDIT 2 / My Own Solution</strong></p>
  
  <p>Found a solution:
  Now I'm checking if the second line overlaps with the region that was the reason for making the second line shorter. If so, I'm truncating the text.
  Functions I used:</p>
  
  <pre><code>TextView.getLineCount()
  TextView.getLayout().getLineStart(int line)
  TextView.getLayout().getLineEnd(int line)
  TextView.getPaint().measureText()
  </code></pre>
  
  <p>Maybe that helps a future anyone.</p>
  
  <p>The question how to set an own layout still remains unanswered, though.</p>