title: How to get number of lines of TextView?
body: <p>I want to get the number of lines of a text view </p>
  
  <pre><code>textView.setText("Test line 1 Test line 2 Test line 3 Test line 4 Test line 5.............")
  </code></pre>
  
  <p><code>textView.getLineCount();</code> always returns <strong>zero</strong></p>
  
  <p>Then I have also tried:</p>
  
  <pre><code>ViewTreeObserver vto = this.textView.getViewTreeObserver();
  vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
  
      @Override
      public void onGlobalLayout() {
          ViewTreeObserver obs = textView.getViewTreeObserver();
          obs.removeGlobalOnLayoutListener(this);
          System.out.println(": " + textView.getLineCount());
  
      }
  });
  </code></pre>
  
  <p>It returns the exact output.</p>
  
  <p>But this works only for a static layout.</p>
  
  <p>When I am inflating the layout dynamically this doesn't work anymore.</p>
  
  <p>How could I find the number of line in a TextView?</p>