1 final TextView textView = new TextView(this); 2 ViewTreeObserver viewTreeObserver = textView.getViewTreeObserver(); 3 viewTreeObserver.addOnPreDrawListener(new OnPreDrawListener() { 4 boolean flag = true; 5 @Override 6 public boolean onPreDraw() { 7 if(flag){ 8 int lineCount = textView.getLineCount(); 9 flag = false; 10 } 11 return false; 12 } 13 });