I have a TextView that I would like to know if it has been truncated due to singleLine="true" in the XML.
What are some ideas to achieve this without having to pass in the displayed text but to detect this with the TextView only?
The answer the OP was looking for was found in the following link: Check if textview is ellipsized in android
The answer basically uses this method to compare the length of the text to the ellipse count to tell if has been truncated.
Layout layout = textview1.getLayout();
if(layout != null) {
int lines = layout.getLineCount();
if(lines > 0) {
int ellipsisCount = layout.getEllipsisCount(lines-1);
if ( ellipsisCount > 0) {
Log.d(TAG, "Text is ellipsized");
}
}
}