Check if textview is ellipsized in android I try to use this but doesnt work. Some guy said add Runnable to this but it seems still doesnt work. Any help?
This is my code.
fun isShownLoadMoreButton(
tvDescription: TextView,
btnReadMore: TextView,
description: String
) {
if (description.isEmpty()) {
btnReadMore.visibility = View.GONE
} else {
tvDescription.apply {
ellipsize = TextUtils.TruncateAt.END
maxLines = MAX_LINE_DESCRIPTION
if (layout != null) {
val lines: Int = layout.lineCount
if (lines > 0) {
val ellipsisCount: Int = layout.getEllipsisCount(lines - 1)
if (ellipsisCount > 0) {
btnReadMore.visibility = View.VISIBLE
} else {
btnReadMore.visibility = View.GONE
}
}
}
}
}
}