Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if TextView text content has been cut off

Tags:

android

I can set max line in my TextView in layout xml file. In my code, after I call setText() to the TextView, how can I find out if the text content has been cut off (i.e. the text is longer than the max line)?

Thank you.

like image 342
richard Avatar asked May 20 '10 17:05

richard


1 Answers

I know this is an old question, but I came across it in my search for a similar answer and wanted to offer the solution that I found, in case anyone else is wondering.

This worked for me:

TextView myTextView = rootView.getViewById(R.id.my_text_view);
if (myTextView.getLineCount() > myTextView.getMaxLines()) {
  // your code here
}
like image 156
Sarah Avatar answered Oct 11 '22 06:10

Sarah