安卓Textview的getLineCount返回0
ViewTreeObserver observer = tv.getViewTreeObserver(); // textAbstract为TextView控件 observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ViewTreeObserver obs = tv.getViewTreeObserver(); obs.removeGlobalOnLayoutListener(this); if (tv.getLineCount() >= 2) { System.out.println("行数" + tv.getLineCount()); } } });